mirror of
https://github.com/YuJunZhiXue/dsh-purge.git
synced 2026-11-28 11:50:23 +08:00
fix: 停用/卸载时清掉 selectedDefault=redteam(#108)
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
fefae8764c
commit
7a78399e0b
6 files changed
+77
-17
No files matched your search
+26
-2
@@ -38,8 +38,10 @@ function listProfilePatchFiles(dshHome) {
|
||||
}
|
||||
for (const name of names) {
|
||||
if (name === "node_modules") continue;
|
||||
const fp = path.join(root, name, "cordis.patch.yml");
|
||||
if (fs.existsSync(fp)) out.push(fp);
|
||||
for (const file of ["cordis.patch.yml", "cordis.yml"]) {
|
||||
const fp = path.join(root, name, file);
|
||||
if (fs.existsSync(fp)) out.push(fp);
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
@@ -167,6 +169,28 @@ export function clearOwnedSelectedDefault({ ctx = null, dshHome = "" } = {}) {
|
||||
return report;
|
||||
}
|
||||
|
||||
let pendingClear = null;
|
||||
|
||||
/** 热重载会先 dispose 再 apply:延迟写盘,apply 进来就取消,避免把用户的红队默认冲掉。 */
|
||||
export function scheduleClearOwnedSelectedDefault(opts = {}) {
|
||||
if (pendingClear) {
|
||||
clearTimeout(pendingClear);
|
||||
pendingClear = null;
|
||||
}
|
||||
pendingClear = setTimeout(() => {
|
||||
pendingClear = null;
|
||||
try { clearOwnedSelectedDefault(opts); } catch { /* 停用不被清默认挡住 */ }
|
||||
try { removeStaleAgentPresetDir(opts.dshHome, "redteam"); } catch { /* ignore */ }
|
||||
}, 800);
|
||||
if (typeof pendingClear.unref === "function") pendingClear.unref();
|
||||
}
|
||||
|
||||
export function cancelClearOwnedSelectedDefault() {
|
||||
if (!pendingClear) return;
|
||||
clearTimeout(pendingClear);
|
||||
pendingClear = null;
|
||||
}
|
||||
|
||||
export function removeStaleAgentPresetDir(dshHome, id = "redteam") {
|
||||
const home = dshHome || findDshHome();
|
||||
if (!home || !id) return false;
|
||||
|
||||
Reference in new issue
Block a user