From cdec7e2db3d7c689879af65241bde629975233e3 Mon Sep 17 00:00:00 2001 From: Boni Garcia Date: Mon, 18 Mar 2024 18:23:05 +0100 Subject: [PATCH] [rust] Use shell command to move extracted Edge to cache --- rust/src/files.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/rust/src/files.rs b/rust/src/files.rs index 0191e858051a5..fc1e3be7e57d1 100644 --- a/rust/src/files.rs +++ b/rust/src/files.rs @@ -139,7 +139,7 @@ pub fn uncompress( } else if extension.eq_ignore_ascii_case(EXE) { uncompress_sfx(compressed_file, target, log)? } else if extension.eq_ignore_ascii_case(DEB) { - uncompress_deb(compressed_file, target, log, volume.unwrap_or_default())? + uncompress_deb(compressed_file, target, log, os, volume.unwrap_or_default())? } else if extension.eq_ignore_ascii_case(MSI) { install_msi(compressed_file, log, os)? } else if extension.eq_ignore_ascii_case(XML) || extension.eq_ignore_ascii_case(HTML) { @@ -264,6 +264,7 @@ pub fn uncompress_deb( compressed_file: &str, target: &Path, log: &Logger, + os: &str, label: &str, ) -> Result<(), Error> { let zip_parent = Path::new(compressed_file).parent().unwrap(); @@ -279,13 +280,17 @@ pub fn uncompress_deb( let zip_parent_str = path_to_string(zip_parent); let target_str = path_to_string(target); - let opt_edge_str = format!("{}/opt/microsoft/{}", zip_parent_str, label); + let opt_edge_str = format!( + "mv {}/opt/microsoft/{} {}", + zip_parent_str, label, target_str + ); + let command = Command::new_single(opt_edge_str.clone()); log.trace(format!( "Moving extracted files and folders from {} to {}", opt_edge_str, target_str )); create_parent_path_if_not_exists(target)?; - fs::rename(&opt_edge_str, &target_str)?; + run_shell_command_by_os(os, command)?; Ok(()) }