Scraper: stop walking the whole library once a minute for status polls
The reader polled /api/state every 15 s; each call rebuilt the scraper's library summary when it was over 60 s old, reading every chapter.json (on the NAS about 5,300 opens / 16,000 NFS calls and 1.3 s CPU per walk, once a minute, plus 115 KB per poll). The reader now polls GET /api/revision (falls back to /api/state on an older scraper), and the summary is rebuilt after a library change or after 15 minutes. Release-date writes invalidate it too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
b328ad98fa
commit
03767d5704
5 files changed
+40
-7
No files matched your search
@@ -80,6 +80,23 @@ test('background inventory failures are visible without breaking controls or lau
|
||||
assert.equal(scans, 2);
|
||||
});
|
||||
|
||||
test('status polling walks the library again only after a change or after 15 minutes', async () => {
|
||||
let scans = 0;
|
||||
const service = fixture(async () => { scans++; return inventory('Demo'); });
|
||||
await service.libraryInventory(true);
|
||||
service.inventoryCachedAt = Date.now() - 10 * 60000; service.inventoryAttemptedAt = 0;
|
||||
for (let n = 0; n < 5; n++) await service.publicState();
|
||||
assert.equal(scans, 1);
|
||||
assert.deepEqual(service.revision(), { publishedRevision: 0, status: 'paused', paused: true });
|
||||
assert.equal(scans, 1);
|
||||
service.invalidateInventory();
|
||||
await service.publicState(); await service.inventoryRefresh;
|
||||
assert.equal(scans, 2);
|
||||
service.inventoryCachedAt = Date.now() - 16 * 60000; service.inventoryAttemptedAt = 0;
|
||||
await service.publicState(); await service.inventoryRefresh;
|
||||
assert.equal(scans, 3);
|
||||
});
|
||||
|
||||
test('dashboard polling reuses a recent snapshot while decisions still force a fresh scan', async () => {
|
||||
let scans = 0;
|
||||
const service = fixture(async () => { scans++; return inventory('Demo'); });
|
||||
|
||||
Reference in new issue
Block a user