Reconcile stale running scrapes and allow per-scrape delete
This commit is contained in:
@@ -25,7 +25,13 @@ import { betterCandidate } from "../src/dedupe.js";
|
||||
import { aspectCondition, resolutionCondition } from "../src/filter-presets.js";
|
||||
import { isNearLimit, planRetention } from "../src/retention.js";
|
||||
import { isoFromSnowflake, snowflakeFromIso } from "../src/snowflake.js";
|
||||
import { dirSizeBytes, listScrapes, ScrapeStore } from "../src/store.js";
|
||||
import {
|
||||
dirSizeBytes,
|
||||
listScrapes,
|
||||
readScrapeMeta,
|
||||
ScrapeStore,
|
||||
writeScrapeMeta
|
||||
} from "../src/store.js";
|
||||
import type { CoreAttachment, CoreMessage } from "../src/types.js";
|
||||
|
||||
let failures = 0;
|
||||
@@ -877,6 +883,25 @@ void (async () => {
|
||||
assert.equal(existsSync(join(dir, `${poster?.hash}.webp`)), true);
|
||||
});
|
||||
|
||||
await test("stale running scrapes are paused on reconcile", async () => {
|
||||
const backend = new FakeBackend([{ messages: [message("1400")] }]);
|
||||
const engine = engineFor(root, backend);
|
||||
const started = await engine.start({ channelId: "170", guildId: null, mode: "links", backend });
|
||||
await engine.processQueue();
|
||||
|
||||
// Simulate a daemon that died mid-job: the meta still says running.
|
||||
const dir = join(root, started.id);
|
||||
const meta = readScrapeMeta(dir);
|
||||
assert.ok(meta);
|
||||
meta.state = "running";
|
||||
writeScrapeMeta(dir, meta);
|
||||
|
||||
const fresh = new ScrapeEngine({ rootDir: root, previews: false });
|
||||
const stale = fresh.reconcileStaleJobs();
|
||||
assert.deepEqual(stale, [started.id]);
|
||||
assert.equal(readScrapeMeta(dir)?.state, "paused");
|
||||
});
|
||||
|
||||
await test("markPreview stores the animated gif reference", () => {
|
||||
const dir = join(root, "anim-store");
|
||||
mkdirSync(dir, { recursive: true });
|
||||
|
||||
Reference in New Issue
Block a user