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:
wonfen
2026-08-21 19:32:15 +08:00
parent b1e953e495
commit 19401b096d
2 changed files with 9 additions and 0 deletions
+5
View File
@@ -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);