From 19401b096d3320093911a0238a464caa715e3887 Mon Sep 17 00:00:00 2001 From: wonfen Date: Fri, 21 Aug 2026 19:30:27 +0800 Subject: [PATCH] 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. --- src-tauri/packages/windows/installer.nsi | 4 ++++ src-tauri/src/feat/core_upgrade.rs | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/src-tauri/packages/windows/installer.nsi b/src-tauri/packages/windows/installer.nsi index f486688d9..1daeaa956 100644 --- a/src-tauri/packages/windows/installer.nsi +++ b/src-tauri/packages/windows/installer.nsi @@ -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| ~}} diff --git a/src-tauri/src/feat/core_upgrade.rs b/src-tauri/src/feat/core_upgrade.rs index f4d72b819..7c677f196 100644 --- a/src-tauri/src/feat/core_upgrade.rs +++ b/src-tauri/src/feat/core_upgrade.rs @@ -99,6 +99,11 @@ pub async fn upgrade_core(force: bool) -> Result { } // 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);