mirror of
https://github.com/YuJunZhiXue/dsh-purge.git
synced 2026-11-28 10:20:22 +08:00
fix: 发布 1.1.53,修应用后无限重启与市场 git 安装(#58–#61)
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
fccb633937
commit
c67b012bd7
11 files changed
+325
-59
No files matched your search
+49
-18
@@ -393,43 +393,74 @@ function shimNeedsPatch(state) {
|
||||
|
||||
async function settleInstalledPatches(config, ctx) {
|
||||
try { core.rememberUnpackedArchive(); } catch { /* 没有官方安装目录时不必记归档 */ }
|
||||
if (officialUpdate.upgradeMarkerExists(process.execPath)) {
|
||||
const upgraded = await reapply.reapplyInstalled({ scheduleSwap: false, upgrade: true });
|
||||
if (!upgraded.ok) {
|
||||
log(config, "official upgrade reapply failed:", upgraded.error || "");
|
||||
return "reapply-failed";
|
||||
}
|
||||
officialUpdate.clearUpgradeMarker(process.execPath);
|
||||
officialUpdate.clearStaleExtractedApps(process.execPath);
|
||||
log(config, "official upgrade reapplied; restarting onto the new build");
|
||||
try {
|
||||
hostctl.scheduleRestart(null, ctx);
|
||||
} catch (e) {
|
||||
log(config, "restart after official upgrade failed:", String(e && e.message ? e.message : e));
|
||||
return "restart-failed";
|
||||
}
|
||||
return "restarting";
|
||||
try {
|
||||
reapply.ensureInstalledRevSeed();
|
||||
} catch (e) {
|
||||
log(config, "seed installed-rev failed:", String(e && e.message ? e.message : e));
|
||||
}
|
||||
try {
|
||||
if (reapply.healEmptyAppliedStamp()) log(config, "healed empty applied stamp");
|
||||
} catch (e) {
|
||||
log(config, "heal applied stamp failed:", String(e && e.message ? e.message : e));
|
||||
}
|
||||
|
||||
if (!reapply.patchesMatchInstall()) {
|
||||
if (officialUpdate.upgradeMarkerExists(process.execPath)) {
|
||||
const upgraded = await reapply.reapplyInstalled({ scheduleSwap: false, upgrade: true });
|
||||
if (!upgraded.ok) {
|
||||
log(config, "official upgrade reapply failed:", upgraded.error || "");
|
||||
return "reapply-failed";
|
||||
}
|
||||
officialUpdate.clearUpgradeMarker(process.execPath);
|
||||
officialUpdate.clearStaleExtractedApps(process.execPath);
|
||||
if (reapply.shouldSkipSettleRestart()) {
|
||||
log(config, "official upgrade reapplied; skip settle restart (cooldown)");
|
||||
return "reapplied-no-restart";
|
||||
}
|
||||
reapply.markSettleRestart();
|
||||
log(config, "official upgrade reapplied; restarting onto the new build");
|
||||
try {
|
||||
hostctl.scheduleRestart(null, ctx, { openBrowser: false });
|
||||
} catch (e) {
|
||||
log(config, "restart after official upgrade failed:", String(e && e.message ? e.message : e));
|
||||
return "restart-failed";
|
||||
}
|
||||
return "restarting";
|
||||
}
|
||||
|
||||
const result = await reapply.reapplyInstalled();
|
||||
if (!result.ok) {
|
||||
log(config, "reapply failed:", result.error || "");
|
||||
return "reapply-failed";
|
||||
}
|
||||
// reapply 成功后强制保证非空戳,避免 clean 路径漏写又空转(#59/#60)。
|
||||
try { reapply.markPatchesApplied(); } catch { /* ignore */ }
|
||||
if (result.needsFullQuit) {
|
||||
bootFullQuit = true;
|
||||
log(config, "reapply wrote patches; official host needs a full quit");
|
||||
return "full-quit";
|
||||
}
|
||||
if (reapply.shouldSkipSettleRestart()) {
|
||||
log(config, "reapply wrote patches; skip settle restart (cooldown)");
|
||||
return "reapplied-no-restart";
|
||||
}
|
||||
// 已对齐则不必再重启;只在 stamp/宿主仍不一致时重启一次。
|
||||
if (reapply.patchesMatchInstall()) {
|
||||
log(config, "reapply wrote patches; already aligned, no restart");
|
||||
return "reapplied";
|
||||
}
|
||||
reapply.markSettleRestart();
|
||||
log(config, "reapply wrote patches; restarting");
|
||||
try {
|
||||
hostctl.scheduleRestart(null, ctx);
|
||||
// web:自愈重启不弹浏览器,关窗后不应再被反复拉起新窗口(#59/#61)。
|
||||
hostctl.scheduleRestart(null, ctx, { openBrowser: false });
|
||||
} catch (e) {
|
||||
log(config, "restart after reapply failed:", String(e && e.message ? e.message : e));
|
||||
return "restart-failed";
|
||||
}
|
||||
return "restarting";
|
||||
}
|
||||
|
||||
const applied = await autoApply(config);
|
||||
if (config.autoUpdateOnStart === true) {
|
||||
updater.autoUpdateIfNeeded()
|
||||
@@ -437,7 +468,7 @@ async function settleInstalledPatches(config, ctx) {
|
||||
log(config, "auto-update:", JSON.stringify(r));
|
||||
if (r && r.needsFullQuit) bootFullQuit = true;
|
||||
if (r && r.restartAfter) {
|
||||
try { hostctl.scheduleRestart(null, ctx); } catch (e) {
|
||||
try { hostctl.scheduleRestart(null, ctx, { openBrowser: false }); } catch (e) {
|
||||
console.warn("[dsh-purge] auto-update restart failed:", e);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user