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
+22
View File
@@ -384,6 +384,28 @@ export class MediaService {
this.engine.stop(id);
}
/** Continue a paused scrape from its cursor with the same backend family. */
async resumeScrape(scrapeId: string): Promise<ScrapeMeta | null> {
const meta = this.engine.get(scrapeId);
if (!meta) return null;
let backend: ScrapeBackend;
if (meta.backend === "slopbot" && meta.guildId) {
const available = await this.ensureSlopbot();
const inGuild = this.bot?.guilds.cache.has(meta.guildId) ?? false;
const fetcher = this.botFetcher;
if (!available || !inGuild || !fetcher) {
throw new Error("slopbot is not connected to that guild");
}
backend = new SlopbotBackend(fetcher);
} else {
backend = this.puppetBackend();
}
this.deps.log?.(`resuming scrape ${scrapeId} from cursor ${meta.cursor ?? "start"}`);
return this.engine.resume(scrapeId, backend);
}
listScrapes(): ScrapeMeta[] {
return this.engine.list();
}