fix(core): upgrade mihomo atomically instead of letting it self-update

mihomo's updater truncates its own running executable in place; macOS kills
that under Hardened Runtime and leaves a 0-byte core. Verge now downloads the
release, verifies a staged copy next to the target, and renames it into place,
which never touches the inode the running core executes from.

Closes #6834
This commit is contained in:
wonfen
2026-08-21 14:41:57 +08:00
parent e71cf0ec68
commit 1b75ea34f9
9 changed files with 529 additions and 12 deletions
+10
View File
@@ -118,6 +118,16 @@ pub async fn restart_core() -> CmdResult {
result
}
/// Replaces the managed core binary atomically instead of letting mihomo overwrite itself.
#[tauri::command]
pub async fn upgrade_clash_core(force: bool) -> CmdResult<feat::CoreUpgradeReport> {
let report = feat::upgrade_core(force).await.with_error_code("CORE_UPGRADE_FAILED")?;
if report.upgraded {
handle::Handle::refresh_clash();
}
Ok(report)
}
#[tauri::command]
pub async fn test_delay(url: String) -> CmdResult<u32> {
let result = match feat::test_delay(url).await {