Preserve per-source pacing across queue jobs and add source pause

This commit is contained in:
Codex committed 2026-10-14 09:23:04 +02:00
1 parent a08e847932
commit a22913129a
8 files changed
+76 -7

No files matched your search

+17
View File
@@ -634,6 +634,23 @@ class ScraperService {
}
async control(action, id) {
if (action === 'pause-source' || action === 'resume-source') {
const source = String(id || '');
if (!this.adapterList.some(adapter => adapter.id === source)) throw new Error('Unknown source');
if (action === 'resume-source' && this.state.queue.some(item => item.source === source
&& item.status === 'error' && item.failure?.kind === 'access')) {
throw new Error('Review the source access block before resuming');
}
if (action === 'pause-source') {
this.state.sourcePaused[source] = true;
const activeId = this.state.currentIds[source];
const activeItem = this.state.queue.find(item => item.id === activeId);
if (activeItem) activeItem.stopReason = 'paused';
} else delete this.state.sourcePaused[source];
this.recomputeStatus();
await this.event('info', `${source} source ${action === 'pause-source' ? 'paused' : 'resumed'} by operator`, { source });
return;
}
if (action === 'inspect' || action === 'confirm') {
const item = this.state.queue.find(entry => entry.id === id);
if (!item || Object.values(this.state.currentIds || {}).includes(item.id)) throw new Error('Job not found or already active');