mirror of
https://github.com/velopack/velopack.git
synced 2025-10-25 15:19:22 +00:00
Fix bug: not cleaning up temp dirs
This commit is contained in:
@@ -22,12 +22,16 @@ pub fn uninstall(locator: &VelopackLocator, delete_self: bool) -> Result<()> {
|
||||
info!("Removing directory '{:?}'", root_path);
|
||||
let _ = remove_dir_all::remove_dir_contents(&root_path);
|
||||
|
||||
let temp_dir = std::env::temp_dir();
|
||||
let temp_dir = temp_dir.join(format!("velopack_{}", locator.get_manifest_id()));
|
||||
|
||||
info!("Removing directory '{:?}'", temp_dir);
|
||||
let _ = remove_dir_all::remove_dir_all(&temp_dir);
|
||||
|
||||
if let Err(e) = windows::registry::remove_uninstall_entry(&locator) {
|
||||
error!("Unable to remove uninstall registry entry ({}).", e);
|
||||
}
|
||||
|
||||
// if it returns true, it was a success.
|
||||
// if it returns false, it was completed with errors which the user should be notified of.
|
||||
let app_title = locator.get_manifest_title();
|
||||
|
||||
info!("Finished successfully.");
|
||||
|
||||
@@ -85,7 +85,7 @@ public static class MsiBuilder
|
||||
var wixArch = data.IsArm64 ? "arm64" : data.Is64Bit ? "x64" : "x86";
|
||||
Log.Info($"Configuring WiX in {wixArch} mode");
|
||||
|
||||
var _1 = TempUtil.GetTempDirectory(out var outputDir);
|
||||
using var _1 = TempUtil.GetTempDirectory(out var outputDir);
|
||||
var wixId = data.WixId;
|
||||
var wxsPath = Path.Combine(outputDir, wixId + ".wxs");
|
||||
var localizationPath = Path.Combine(outputDir, wixId + "_en-US.wxs");
|
||||
|
||||
@@ -97,14 +97,14 @@
|
||||
|
||||
<!-- deferred actions do not have access to msi properties and read all data from "CustomActionData" which is a string,
|
||||
so we delimit with " which is unlikely (or disallowed) from to appearing in filenames / paths.-->
|
||||
<CustomAction Id="SetRustCleanupData" Property="RustCleanup" Value="[INSTALLFOLDER]"[RustAppId]" Execute="immediate"
|
||||
<CustomAction Id="SetRustCleanupData" Property="RustCleanup" Value="[INSTALLFOLDER]"[RustAppId]"[TempFolder]" Execute="immediate"
|
||||
Return="check"/>
|
||||
<CustomAction Id="RustCleanup" BinaryRef="RustDll" DllEntry="CleanupDeferred" Execute="deferred" Impersonate="no" Return="ignore"/>
|
||||
<CustomAction Id="RustLaunchApplication" BinaryRef="RustDll" DllEntry="LaunchApplication" Impersonate="yes" Execute="immediate"
|
||||
Return="ignore"/>
|
||||
|
||||
<InstallUISequence>
|
||||
<Custom Action="RustEarlyBootstrap" Before="AppSearch" Condition="REMOVE="""/>
|
||||
<Custom Action="RustEarlyBootstrap" Before="AppSearch" Condition="NOT REMOVE AND NOT RustRuntimeDependencies"/>
|
||||
</InstallUISequence>
|
||||
|
||||
<InstallExecuteSequence>
|
||||
|
||||
@@ -48,19 +48,23 @@ pub extern "system" fn CleanupDeferred(h_install: MSIHANDLE) -> c_uint {
|
||||
let mut custom_data = custom_data.split('"');
|
||||
let install_dir = custom_data.next();
|
||||
let app_id = custom_data.next();
|
||||
let temp_dir = custom_data.next();
|
||||
|
||||
show_debug_message("CleanupDeferred", format!("install_dir={:?}, app_id={:?}", install_dir, app_id));
|
||||
show_debug_message("CleanupDeferred", format!("install_dir={:?}, app_id={:?}, temp_dir={:?}", install_dir, app_id, temp_dir));
|
||||
|
||||
if let Some(install_dir) = install_dir {
|
||||
if let Err(e) = remove_dir_all::remove_dir_all(install_dir) {
|
||||
show_debug_message("CleanupDeferred", format!("Failed to remove install directory: {}", e));
|
||||
show_debug_message("CleanupDeferred", format!("Failed to remove install directory: {:?} {}", install_dir, e));
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(app_id) = app_id {
|
||||
let temp_dir = std::env::temp_dir();
|
||||
if let Err(e) = remove_dir_all::remove_dir_all(temp_dir.join(format!("velopack_{}", app_id))) {
|
||||
show_debug_message("CleanupDeferred", format!("Failed to remove temp directory: {}", e));
|
||||
if let Some(temp_dir) = temp_dir {
|
||||
let temp_dir = PathBuf::from(temp_dir);
|
||||
let temp_dir = temp_dir.join(format!("velopack_{}", app_id));
|
||||
if let Err(e) = remove_dir_all::remove_dir_all(&temp_dir) {
|
||||
show_debug_message("CleanupDeferred", format!("Failed to remove temp directory: {:?} {}", temp_dir, e));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user