feat(rclone.exe): Function new()
This function first of all created app object by 1) Defining the application directory 2) Creating dirs if they are not exists 3) Defining ways for rclone by yours os 4) Define rclone or install it
This commit is contained in:
1 parent
d021100ed5
commit
c43d4fdf9c
1 file changed
+22
@@ -1,6 +1,28 @@
|
||||
use std::fs;
|
||||
use std::path::PathBuf;
|
||||
use std::process::Command;
|
||||
|
||||
pub struct RcloneApp {
|
||||
rclone_path: PathBuf,
|
||||
}
|
||||
|
||||
impl RcloneApp {
|
||||
pub fn new() -> Result<Self, Box<dyn std::error::Error>> {
|
||||
let app_dir = dirs::data_dir()
|
||||
.ok_or("Не удалось найти папку для данных")?
|
||||
.join("rclone-ui");
|
||||
|
||||
fs::create_dir_all(&app_dir)?;
|
||||
let rclone_path = if cfg!(windows) {
|
||||
app_dir.join("rclone.exe")
|
||||
} else {
|
||||
app_dir.join("rclone")
|
||||
};
|
||||
|
||||
if !rclone_path.exists() {
|
||||
Self::extract_rclone(&rclone_path)?;
|
||||
}
|
||||
|
||||
Ok(Self { rclone_path })
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user