mirror of
https://github.com/YuJunZhiXue/dsh-purge.git
synced 2026-11-28 07:20:22 +08:00
fix: 解包失败时放回升级前的目录。
升级脚本先挪走旧目录后,解开中途失败会把那一份放回去。补丁没写完不清除升级标记,下次启动再试。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
3ca5b1ec63
commit
b47ebfb976
3 files changed
+26
-13
No files matched your search
+23
-10
@@ -1635,6 +1635,14 @@ export function sealedAsarHandoff(input = {}) {
|
||||
return { exe, asar, swapAsar: true };
|
||||
}
|
||||
|
||||
/** 当前目录还不能当宿主时,把升级脚本或上一次换目录挪走的那一份放回去。能用的目录不动。 */
|
||||
function restoreUnusableExtract(appDir, prev) {
|
||||
if (aiBaseUnderAppDir(appDir)) return false;
|
||||
const saved = prev || newestPreservedDir(appDir);
|
||||
if (!saved) return false;
|
||||
return restoreExtractedDir(appDir, saved);
|
||||
}
|
||||
|
||||
/** 官方 app.asar 解开到 resources/app。已有解开目录时直接用,不重新解包。 */
|
||||
export async function openSealedDesktopHost(options = {}) {
|
||||
const handoff = sealedAsarHandoff();
|
||||
@@ -1644,21 +1652,26 @@ export async function openSealedDesktopHost(options = {}) {
|
||||
let extracted = false;
|
||||
let prev = "";
|
||||
if (!aiBase) {
|
||||
const side = extractAsarToSide(handoff.asar, appDir);
|
||||
overlayAsarUnpacked(handoff.asar, side.next);
|
||||
if (!aiBaseUnderAppDir(side.next)) {
|
||||
try { hostFs.rmSync(side.next, { recursive: true, force: true }); } catch { /* 半成品留在旁边,不覆盖正在用的目录 */ }
|
||||
throw new Error(`已解开 ${handoff.asar},但里面没有 @deepseek-ai`);
|
||||
try {
|
||||
const side = extractAsarToSide(handoff.asar, appDir);
|
||||
overlayAsarUnpacked(handoff.asar, side.next);
|
||||
if (!aiBaseUnderAppDir(side.next)) {
|
||||
try { hostFs.rmSync(side.next, { recursive: true, force: true }); } catch { /* 半成品留在旁边,不覆盖正在用的目录 */ }
|
||||
throw new Error(`已解开 ${handoff.asar},但里面没有 @deepseek-ai`);
|
||||
}
|
||||
const committed = commitExtractedDir(appDir, side.next);
|
||||
prev = committed.prev || "";
|
||||
extracted = true;
|
||||
aiBase = aiBaseUnderAppDir(appDir);
|
||||
} catch (error) {
|
||||
try { restoreUnusableExtract(appDir, prev); } catch { /* 放回失败时旧目录仍留在旁边 */ }
|
||||
throw error;
|
||||
}
|
||||
const committed = commitExtractedDir(appDir, side.next);
|
||||
prev = committed.prev || "";
|
||||
extracted = true;
|
||||
aiBase = aiBaseUnderAppDir(appDir);
|
||||
} else {
|
||||
overlayAsarUnpacked(handoff.asar, appDir);
|
||||
}
|
||||
if (!aiBase) {
|
||||
if (prev) restoreExtractedDir(appDir, prev);
|
||||
restoreUnusableExtract(appDir, prev);
|
||||
throw new Error(`已解开 ${handoff.asar},但 ${appDir} 下没有 @deepseek-ai`);
|
||||
}
|
||||
resetPathMemo();
|
||||
|
||||
+1
-1
@@ -320,11 +320,11 @@ function shimNeedsPatch(state) {
|
||||
async function settleInstalledPatches(config, ctx) {
|
||||
if (officialUpdate.upgradeMarkerExists(process.execPath)) {
|
||||
const upgraded = await reapply.reapplyInstalled({ scheduleSwap: false, forceExtract: true });
|
||||
officialUpdate.clearUpgradeMarker(process.execPath);
|
||||
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 {
|
||||
|
||||
Reference in new issue
Block a user