Reconcile stale running scrapes and allow per-scrape delete

This commit is contained in:
Fisto
2026-09-17 08:40:28 +02:00
parent 0b72422afe
commit d886d22d89
7 changed files with 83 additions and 4 deletions
+19
View File
@@ -208,6 +208,25 @@ export class ScrapeEngine {
return { ...meta };
}
/**
* A scrape left `running` or `queued` on disk has no live job (the daemon that owned it is
* gone). Pause it so the UI shows the truth and Resume can pick it up.
*/
reconcileStaleJobs(): string[] {
const stale: string[] = [];
for (const meta of listScrapes(this.options.rootDir)) {
if (meta.state !== "running" && meta.state !== "queued") continue;
meta.state = "paused";
meta.updatedAt = new Date(this.now()).toISOString();
writeScrapeMeta(join(this.options.rootDir, meta.id), meta);
stale.push(meta.id);
}
return stale;
}
/** Cache previews for rows a finished or paused scrape never reached. Returns the count. */
async backfillPreviews(scrapeId: string): Promise<number> {
const meta = this.active.get(scrapeId) ?? readScrapeMeta(join(this.options.rootDir, scrapeId));