mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-11-08 02:52:07 +08:00
fix(core): clean up the displaced core after a failed upgrade restart
Windows publishes the core by moving the running binary aside, and only the success path could delete it afterwards. A failed restart left it on disk, and the uninstaller did not know about it either.
This commit is contained in:
@@ -1133,6 +1133,10 @@ Section Uninstall
|
||||
Delete "$INSTDIR\\{{this}}"
|
||||
{{/each}}
|
||||
|
||||
; A failed core upgrade leaves the displaced binary behind; it is never user data.
|
||||
Delete "$INSTDIR\verge-mihomo.old"
|
||||
Delete "$INSTDIR\verge-mihomo-alpha.old"
|
||||
|
||||
; Delete app associations
|
||||
{{#each file_associations as |association| ~}}
|
||||
{{#each association.ext as |ext| ~}}
|
||||
|
||||
@@ -99,6 +99,11 @@ pub async fn upgrade_core(force: bool) -> Result<CoreUpgradeReport> {
|
||||
}
|
||||
// Renaming one hard link over the other succeeds without consuming the name.
|
||||
let _ = std::fs::remove_file(&rollback);
|
||||
// Redundant once the rollback link exists; without one it is the only copy left.
|
||||
#[cfg(windows)]
|
||||
if restorable {
|
||||
let _ = std::fs::remove_file(target.with_extension("old"));
|
||||
}
|
||||
return Err(error);
|
||||
}
|
||||
let _ = std::fs::remove_file(&rollback);
|
||||
|
||||
Reference in New Issue
Block a user