fix(sources): 快照开始前收尾本站遗留的运行中记录;v0.3.39

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Cxwgnn2pbzQ7rXv3rq7fei
This commit is contained in:
rootandClaude Opus 5.5 committed 2026-10-08 03:39:00 +08:00
1 parent 5c74666148
commit 8ff1817845
14 files changed
+51 -11

No files matched your search

@@ -59,4 +59,27 @@ describe.skipIf(!up)("快照截止时间", () => {
expect(snap.status).toBe("failed");
expect(snap.finished_at).not.toBeNull();
});
it("旧的「运行中」记录在下一次快照开始时按中断收尾,刚开始的不动", async () => {
const mk = (ago: number) =>
h.db
.insertInto("site_snapshot")
.values({
site_id: siteId,
kind: "periodic",
filters: "{}",
definition_version: "t",
started_at: new Date(Date.now() - ago),
})
.returning("id")
.executeTakeFirstOrThrow();
const stale = await mk(3_600_000);
const fresh = await mk(100);
await snapshotSite(h.rt, { siteId, kind: "periodic" }, { deadlineMs: 300 });
const get = (id: string) =>
h.db.selectFrom("site_snapshot").selectAll().where("id", "=", id).executeTakeFirstOrThrow();
expect(await get(stale.id)).toMatchObject({ status: "failed" });
expect((await get(stale.id)).error).toMatchObject({ message: "上次快照中断,没有收尾" });
expect((await get(fresh.id)).status).toBe("running");
});
});