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
This commit is contained in:
parent
89e92a4739
commit
d73d782659
2 changed files with 28 additions and 8 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"base_url": "http://localhost:8080",
|
"base_url": "http://localhost:8080",
|
||||||
"default_org": {
|
"default_org": {
|
||||||
"id": "350166510557200398",
|
"id": "350170397284499470",
|
||||||
"name": "default",
|
"name": "default",
|
||||||
"domain": "default.localhost"
|
"domain": "default.localhost"
|
||||||
},
|
},
|
||||||
|
|
@ -13,8 +13,8 @@
|
||||||
"first_name": "Admin",
|
"first_name": "Admin",
|
||||||
"last_name": "User"
|
"last_name": "User"
|
||||||
},
|
},
|
||||||
"admin_token": "ljVnxOognfMMqF_EOrkBse3YPEV7pUJDn78z9RFzIgGdzejdC35UfiYK7TSljt2mVaV6p40",
|
"admin_token": "K7-6eQSzh7Lgcb5vuWZGODO1nrIAu1gFv7KxFJoYPSn15NFT8E9-iNy6AFaEQEkE9mb0tK0",
|
||||||
"project_id": "",
|
"project_id": "",
|
||||||
"client_id": "350166511245131790",
|
"client_id": "350170398056316942",
|
||||||
"client_secret": "JovJLn0DFlriDW4mtaDCTZ7cZPWPWCkLQgL7dVoOmhRqD3zMEkEGPTmLb8rISKCO"
|
"client_secret": "ej5NkifamoHntY21FFvz18wygcgFFKtaLpwW4lN1XHwMHRGWb5GrzFxIeaA1iqZu"
|
||||||
}
|
}
|
||||||
|
|
@ -440,7 +440,13 @@ impl PackageManager {
|
||||||
self.install_binary(temp_file, bin_path, name)?;
|
self.install_binary(temp_file, bin_path, name)?;
|
||||||
} else {
|
} else {
|
||||||
let final_path = bin_path.join(temp_file.file_name().unwrap());
|
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)?;
|
self.make_executable(&final_path)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -458,7 +464,11 @@ impl PackageManager {
|
||||||
String::from_utf8_lossy(&output.stderr)
|
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(())
|
Ok(())
|
||||||
}
|
}
|
||||||
pub fn extract_zip(&self, temp_file: &PathBuf, bin_path: &PathBuf) -> Result<()> {
|
pub fn extract_zip(&self, temp_file: &PathBuf, bin_path: &PathBuf) -> Result<()> {
|
||||||
|
|
@ -472,7 +482,11 @@ impl PackageManager {
|
||||||
String::from_utf8_lossy(&output.stderr)
|
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(())
|
Ok(())
|
||||||
}
|
}
|
||||||
pub fn install_binary(
|
pub fn install_binary(
|
||||||
|
|
@ -482,7 +496,13 @@ impl PackageManager {
|
||||||
name: &str,
|
name: &str,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let final_path = bin_path.join(name);
|
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)?;
|
self.make_executable(&final_path)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue