Resume paused scrapes from their cursor

This commit is contained in:
Fisto
2026-09-17 00:14:57 +02:00
parent 089bca0d4f
commit 0664b54241
10 changed files with 110 additions and 0 deletions
+27
View File
@@ -877,6 +877,33 @@ void (async () => {
assert.equal(existsSync(join(dir, `${poster?.hash}.webp`)), true);
});
await test("engine resumes a paused scrape from its cursor", async () => {
const first = new FakeBackend([
{ messages: [message("500"), message("499")] },
{ messages: [message("498")] }
]);
const engine = engineFor(root, first);
const started = await engine.start({ channelId: "140", guildId: null, mode: "links", backend: first });
engine.stop(started.id);
await engine.processQueue();
let meta = engine.get(started.id);
assert.equal(meta?.state, "paused");
assert.equal(meta?.cursor, "499");
assert.equal(meta?.messages, 2);
const second = new FakeBackend([{ messages: [message("498")] }]);
await engine.resume(started.id, second);
await engine.processQueue();
meta = engine.get(started.id);
assert.equal(meta?.state, "done");
assert.equal(meta?.messages, 3);
assert.equal(meta?.cursor, "498");
assert.equal(second.calls[0].before, "499");
});
await test("backfillPreviews fills rows left by a preview-less walk", async () => {
const backend = new FakeBackend([
{