@michengai/dsh-archive-manager 1.1.0 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/CHANGELOG.zh-CN.md +12 -0
- package/lib/client.js +3 -3
- package/lib/projcache.js +10 -3
- package/lib/workspace.js +8 -0
- package/package.json +1 -1
package/lib/projcache.js
CHANGED
|
@@ -241,12 +241,18 @@ var ArchiveProjectionCache = class extends CacheBase {
|
|
|
241
241
|
}
|
|
242
242
|
/**
|
|
243
243
|
* 永久移除一个会话的缓存投影行。
|
|
244
|
+
* 同时清理当前表与底层原生表(如官方 session_projcache 域),防止残留孤儿文件。
|
|
244
245
|
* @param id - 要删除缓存行的会话。
|
|
245
246
|
* @returns 行删除完成后的 resolution。
|
|
246
247
|
*/
|
|
247
248
|
async delete(id) {
|
|
248
249
|
trackTombstone(this.deletedSessionIds, this.deletedSessionOrder, id, this.deletedSessionTombstoneLimit);
|
|
249
|
-
|
|
250
|
+
const tasks = [this.requireTable().delete(id)];
|
|
251
|
+
const secondary = this.secondaryTable;
|
|
252
|
+
if (secondary !== void 0 && typeof secondary.delete === "function") {
|
|
253
|
+
tasks.push(secondary.delete(id).catch(() => false));
|
|
254
|
+
}
|
|
255
|
+
await Promise.all(tasks);
|
|
250
256
|
}
|
|
251
257
|
/** 撤销墓碑(供测试与同 id 新生命周期复用路径使用)。 */
|
|
252
258
|
clearTombstone(id) {
|
|
@@ -256,12 +262,13 @@ var ArchiveProjectionCache = class extends CacheBase {
|
|
|
256
262
|
}
|
|
257
263
|
};
|
|
258
264
|
const projectionGuards = /* @__PURE__ */ new WeakMap();
|
|
259
|
-
function installArchiveProjectionCacheGuards(cache, table) {
|
|
265
|
+
function installArchiveProjectionCacheGuards(cache, table, secondaryTable) {
|
|
260
266
|
const target = Reflect.get(cache, symbols.original) ?? cache;
|
|
261
267
|
const existing = projectionGuards.get(target);
|
|
262
268
|
if (existing) return existing;
|
|
263
269
|
const fields = {
|
|
264
270
|
table: table ?? target.table,
|
|
271
|
+
secondaryTable: secondaryTable !== (table ?? target.table) ? secondaryTable : void 0,
|
|
265
272
|
deletedSessionIds: /* @__PURE__ */ new Set(),
|
|
266
273
|
deletedSessionOrder: [],
|
|
267
274
|
deletedSessionTombstoneLimit: 4096,
|
|
@@ -322,7 +329,7 @@ async function installArchiveProjectionCache(cache) {
|
|
|
322
329
|
try {
|
|
323
330
|
const table = new SafeSessionTable(domain.table("sessions"));
|
|
324
331
|
await importPreviousProjectionCache(target.ctx, table, previousTable);
|
|
325
|
-
uninstallGuards = installArchiveProjectionCacheGuards(cache, table);
|
|
332
|
+
uninstallGuards = installArchiveProjectionCacheGuards(cache, table, previousTable);
|
|
326
333
|
target.table = table;
|
|
327
334
|
target[projectionOverlay] = true;
|
|
328
335
|
installed = true;
|
package/lib/workspace.js
CHANGED
|
@@ -637,6 +637,14 @@ var ArchiveWorkspaceRegistry = class extends WorkspaceRegistry {
|
|
|
637
637
|
const header = this.headers.get(sessionId);
|
|
638
638
|
this.forgetIndexedSession(sessionId);
|
|
639
639
|
if (header !== void 0) this.deletedIdentities.set(sessionId, headerIdentity(header));
|
|
640
|
+
const projCache = this.ctx.get("sessionProjectionCache");
|
|
641
|
+
if (projCache !== void 0 && typeof projCache.delete === "function") {
|
|
642
|
+
try {
|
|
643
|
+
await projCache.delete(sessionId);
|
|
644
|
+
} catch (e) {
|
|
645
|
+
this.ctx.logger.warn(`archive-manager: cleanup projection cache for missing session "${sessionId}" failed: ${String(e)}`);
|
|
646
|
+
}
|
|
647
|
+
}
|
|
640
648
|
continue;
|
|
641
649
|
}
|
|
642
650
|
kept.push(sessionId);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@michengai/dsh-archive-manager",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "归档、恢复、收藏和永久删除会话,并诊断损坏的会话日志。 · Archive, restore, favorite, and permanently delete sessions, and diagnose damaged session logs.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"packageManager": "pnpm@11.22.0",
|