From 281406a92033d4874f6fe7b334a1362acb9b3527 Mon Sep 17 00:00:00 2001 From: Kirill Date: Tue, 24 Feb 2026 11:03:23 +0300 Subject: [PATCH] feat(rclone.exe): method extract_rclone(): extracts the internal binary --- src/rcloneInstall.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/rcloneInstall.rs b/src/rcloneInstall.rs index 7cacb94..7534c18 100644 --- a/src/rcloneInstall.rs +++ b/src/rcloneInstall.rs @@ -25,4 +25,31 @@ impl RcloneApp { Ok(Self { rclone_path }) } + + fn extract_rclone(dest_path: &PathBuf) -> Result<(), Box> { + 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(()) + } }