Allow queued confirmation during source pause
This commit is contained in:
1 parent
a22913129a
commit
b96ab42add
4 files changed
+51
-5
No files matched your search
+6
-1
@@ -654,7 +654,12 @@ class ScraperService {
|
||||
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');
|
||||
if (this.state.sourcePaused[item.source] || item.failure?.kind === 'access') throw new Error('Review the source access block before inspecting or confirming');
|
||||
// Confirmation only changes the persisted queue. The work loop still
|
||||
// refuses to start jobs for a paused source, so an admin can approve an
|
||||
// already inspected edition without accidentally retrying blocked access.
|
||||
if (item.failure?.kind === 'access' || (action === 'inspect' && this.state.sourcePaused[item.source])) {
|
||||
throw new Error('Review the source access block before inspecting');
|
||||
}
|
||||
if (action === 'confirm') {
|
||||
if (item.status !== 'ready' || item.kind !== 'inspection') throw new Error('Inspect the source first');
|
||||
item.confirmedSourceTitle = item.sourceTitle;
|
||||
|
||||
@@ -24,3 +24,19 @@ test('an operator can pause one source while other lanes continue', async t => {
|
||||
await service.control('resume-source', 'weebcentral');
|
||||
assert.equal(service.state.sourcePaused.weebcentral, undefined);
|
||||
});
|
||||
|
||||
test('confirmation can queue an inspected job without unpausing its source', async t => {
|
||||
const root = await fs.mkdtemp(path.join(os.tmpdir(), 'mc-source-confirm-'));
|
||||
const service = await new ScraperService({ libraryRoot: path.join(root, 'library'),
|
||||
dataRoot: path.join(root, 'data') }).init();
|
||||
t.after(async () => { await service.close(); await fs.rm(root, { recursive: true, force: true }); });
|
||||
const item = { id: 'inspected', source: 'weebcentral', title: 'Sample', sourceTitle: 'Sample',
|
||||
kind: 'inspection', status: 'ready' };
|
||||
service.state.queue.push(item);
|
||||
await service.control('pause-source', 'weebcentral');
|
||||
await service.control('confirm', item.id);
|
||||
assert.equal(item.kind, 'download');
|
||||
assert.equal(item.status, 'queued');
|
||||
assert.equal(service.state.sourcePaused.weebcentral, true);
|
||||
await assert.rejects(service.control('inspect', item.id), /source access block/);
|
||||
});
|
||||
Reference in new issue
Block a user