feat(rclone.exe): method extract_rclone():
extracts the internal binary
This commit is contained in:
1 parent
c43d4fdf9c
commit
281406a920
1 file changed
+27
@@ -25,4 +25,31 @@ impl RcloneApp {
|
||||
|
||||
Ok(Self { rclone_path })
|
||||
}
|
||||
|
||||
fn extract_rclone(dest_path: &PathBuf) -> Result<(), Box<dyn std::error::Error>> {
|
||||
println!("Устанавливаю rclone в {:?}", dest_path);
|
||||
|
||||
let rclone_bytes = if cfg!(windows) {
|
||||
include_bytes!("../bin/rclone.exe")
|
||||
} else if cfg!(target_os = "linux") {
|
||||
include_bytes!("../bin/rclone")
|
||||
} else if cfg!(target_os = "macos") {
|
||||
include_bytes!("../bin/rclone")
|
||||
} else {
|
||||
panic!("Неподдерживаемая ОС");
|
||||
};
|
||||
|
||||
fs::write(dest_path, rclone_bytes)?;
|
||||
|
||||
#[cfg(not(windows))]
|
||||
{
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
let mut perms = fs::metadata(dest_path)?.permissions();
|
||||
perms.set_mode(0o755); // rwxr-xr-x
|
||||
fs::set_permissions(dest_path, perms)?;
|
||||
}
|
||||
|
||||
println!("rclone успешно установлен!");
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user