From 559154b92302836e67c1e1d2a56c1ef99842ba5d Mon Sep 17 00:00:00 2001 From: "Rodrigo Rodriguez (Pragmatismo)" Date: Mon, 8 Dec 2025 14:19:55 -0300 Subject: [PATCH] fix: preserve cached files in botserver-installers after extraction - Don't delete archive files from cache after tar/zip extraction - Copy binaries from cache instead of moving them - Cached files are now preserved for offline installation reuse --- config/directory_config.json | 8 ++++---- src/core/package_manager/facade.rs | 28 ++++++++++++++++++++++++---- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/config/directory_config.json b/config/directory_config.json index 3a0e3e002..d03748053 100644 --- a/config/directory_config.json +++ b/config/directory_config.json @@ -1,7 +1,7 @@ { "base_url": "http://localhost:8080", "default_org": { - "id": "350166510557200398", + "id": "350170397284499470", "name": "default", "domain": "default.localhost" }, @@ -13,8 +13,8 @@ "first_name": "Admin", "last_name": "User" }, - "admin_token": "ljVnxOognfMMqF_EOrkBse3YPEV7pUJDn78z9RFzIgGdzejdC35UfiYK7TSljt2mVaV6p40", + "admin_token": "K7-6eQSzh7Lgcb5vuWZGODO1nrIAu1gFv7KxFJoYPSn15NFT8E9-iNy6AFaEQEkE9mb0tK0", "project_id": "", - "client_id": "350166511245131790", - "client_secret": "JovJLn0DFlriDW4mtaDCTZ7cZPWPWCkLQgL7dVoOmhRqD3zMEkEGPTmLb8rISKCO" + "client_id": "350170398056316942", + "client_secret": "ej5NkifamoHntY21FFvz18wygcgFFKtaLpwW4lN1XHwMHRGWb5GrzFxIeaA1iqZu" } \ No newline at end of file diff --git a/src/core/package_manager/facade.rs b/src/core/package_manager/facade.rs index f027c2032..ce25e832f 100644 --- a/src/core/package_manager/facade.rs +++ b/src/core/package_manager/facade.rs @@ -440,7 +440,13 @@ impl PackageManager { self.install_binary(temp_file, bin_path, name)?; } else { let final_path = bin_path.join(temp_file.file_name().unwrap()); - std::fs::rename(temp_file, &final_path)?; + // Copy instead of rename if source is in cache directory + // This preserves cached files for offline installation + if temp_file.to_string_lossy().contains("botserver-installers") { + std::fs::copy(temp_file, &final_path)?; + } else { + std::fs::rename(temp_file, &final_path)?; + } self.make_executable(&final_path)?; } } @@ -458,7 +464,11 @@ impl PackageManager { String::from_utf8_lossy(&output.stderr) )); } - std::fs::remove_file(temp_file)?; + // Only delete if NOT in the cache directory (botserver-installers) + // Cached files should be preserved for offline installation + if !temp_file.to_string_lossy().contains("botserver-installers") { + std::fs::remove_file(temp_file)?; + } Ok(()) } pub fn extract_zip(&self, temp_file: &PathBuf, bin_path: &PathBuf) -> Result<()> { @@ -472,7 +482,11 @@ impl PackageManager { String::from_utf8_lossy(&output.stderr) )); } - std::fs::remove_file(temp_file)?; + // Only delete if NOT in the cache directory (botserver-installers) + // Cached files should be preserved for offline installation + if !temp_file.to_string_lossy().contains("botserver-installers") { + std::fs::remove_file(temp_file)?; + } Ok(()) } pub fn install_binary( @@ -482,7 +496,13 @@ impl PackageManager { name: &str, ) -> Result<()> { let final_path = bin_path.join(name); - std::fs::rename(temp_file, &final_path)?; + // Copy instead of rename if source is in cache directory + // This preserves cached files for offline installation + if temp_file.to_string_lossy().contains("botserver-installers") { + std::fs::copy(temp_file, &final_path)?; + } else { + std::fs::rename(temp_file, &final_path)?; + } self.make_executable(&final_path)?; Ok(()) }