mirror of
https://github.com/YuJunZhiXue/dsh-purge.git
synced 2026-11-28 01:10:22 +08:00
fix: 发布 1.1.27,修应用重启后进规则设定仍弹「需要重启」
- 手动应用成功后写入 applied 戳,避免重启 settle 误判未对齐再要求重启 - 点重启时清掉 boot_full_quit 粘性标记;status 按布尔值同步弹窗 - web waitForRestart 必须先看到旧进程掉线再判定成功,避免同进程误刷新又弹窗 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
4321b3a039
commit
e360fa6b70
4 files changed
+23
-4
No files matched your search
@@ -1031,7 +1031,7 @@ window.__ModuleLoader__.load({ id: "dsh-purge", factory: (require) => {
|
||||
setState(d);
|
||||
if (d.channel) setChannel(d.channel);
|
||||
if (d.update && d.update.ok && !d.update.error) setUpdateInfo(d.update);
|
||||
if (d.boot_full_quit) setAskOfficialRestart(true);
|
||||
setAskOfficialRestart(Boolean(d.boot_full_quit));
|
||||
} else {
|
||||
setState({ ok: false, patches_total: 0, patches_applied: 0, patch_status: {}, shim_cmd: "n/a", shim_ps1: "n/a", shim_bin: "n/a", has_backup: false });
|
||||
setNotice({ kind: "error", text: tr("err.status", { error: (d && d.error) || "bad response" }) });
|
||||
@@ -2031,14 +2031,23 @@ window.__ModuleLoader__.load({ id: "dsh-purge", factory: (require) => {
|
||||
|
||||
function waitForRestart(setNotice, setBusy, t) {
|
||||
const started = Date.now();
|
||||
// 必须先看到旧进程掉线,再等新进程就绪;否则同进程立刻 200 会被当成「重启成功」又弹重启。
|
||||
let sawDown = false;
|
||||
const ping = () => {
|
||||
fetch("/dsh-purge/status", { cache: "no-store", credentials: "same-origin" })
|
||||
.then((r) => (r.ok ? r.json() : Promise.reject()))
|
||||
.then((d) => {
|
||||
if (!sawDown) {
|
||||
retry();
|
||||
return;
|
||||
}
|
||||
if (d && d.ok && d.ready !== false) reopenAfterRestart();
|
||||
else retry();
|
||||
})
|
||||
.catch(retry);
|
||||
.catch(() => {
|
||||
sawDown = true;
|
||||
retry();
|
||||
});
|
||||
};
|
||||
const retry = () => {
|
||||
if (Date.now() - started > 90000) {
|
||||
|
||||
@@ -1232,6 +1232,8 @@ function installWebServer(ctx, cfg) {
|
||||
pendingQuit = Boolean(swapped?.pending);
|
||||
}
|
||||
const leaveTray = renamed || pendingQuit;
|
||||
if (complete) reapply.markPatchesApplied();
|
||||
if (leaveTray) bootFullQuit = true;
|
||||
sendJson(response, 200, {
|
||||
ok: true,
|
||||
complete,
|
||||
@@ -1371,6 +1373,8 @@ function installWebServer(ctx, cfg) {
|
||||
try {
|
||||
const surface = hostctl.currentSurface();
|
||||
const planned = hostctl.scheduleRestart(request, ctx);
|
||||
// 用户已点重启:清掉粘性标记,避免同进程误刷新/再进面板又弹一次。
|
||||
bootFullQuit = false;
|
||||
sendJson(response, 200, {
|
||||
ok: true,
|
||||
surface,
|
||||
|
||||
+7
-1
@@ -64,6 +64,11 @@ function writeAppliedStamp(sha) {
|
||||
}, null, 2)}\n`, "utf8");
|
||||
}
|
||||
|
||||
/** 手动「应用」成功后也要打戳,否则重启后 settle 会以为补丁未对齐再要求重启。 */
|
||||
export function markPatchesApplied(sha) {
|
||||
writeAppliedStamp(sha == null ? installedRev() : sha);
|
||||
}
|
||||
|
||||
/**
|
||||
* 先把宿主文件从备份还原,再按当前这份插件的补丁重写。
|
||||
* 低版本带着自己的补丁列表,高版本带着自己的;回退到哪一版就打哪一版。
|
||||
@@ -103,6 +108,7 @@ export async function reapplyInstalled(options = {}) {
|
||||
}
|
||||
const summary = core.summarizeApplyReport(report);
|
||||
writeAppliedStamp(installedRev());
|
||||
const pending = Boolean(handoff?.asar && !renamed && options.scheduleSwap !== false);
|
||||
return {
|
||||
ok: true,
|
||||
version: pluginVersion(),
|
||||
@@ -110,7 +116,7 @@ export async function reapplyInstalled(options = {}) {
|
||||
applied: summary.applied || 0,
|
||||
failed: summary.failed.length,
|
||||
renamed,
|
||||
needsFullQuit: renamed || core.officialHostMustStayUp(),
|
||||
needsFullQuit: renamed || pending || core.officialHostMustStayUp(),
|
||||
cmdFlashOk: flash.ok === true,
|
||||
};
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "dsh-purge",
|
||||
"version": "1.1.26",
|
||||
"version": "1.1.27",
|
||||
"description": "DeepSeek Harness 网络安全红队工具:本机官方 Harness 受控评测与清洗,不同模型可换不同提示词;默认提示词面向国模「小码酱」。求 Star ⭐",
|
||||
"type": "module",
|
||||
"main": "lib/index.js",
|
||||
|
||||
Reference in new issue
Block a user