Handle large WeebCentral catalogs and correct MangaPill checkpoint monitoring
This commit is contained in:
1 parent
0d51f214d5
commit
edbc9c6056
11 files changed
+102
-7
No files matched your search
@@ -0,0 +1,40 @@
|
||||
'use strict';
|
||||
|
||||
const test = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
const fs = require('node:fs/promises');
|
||||
const os = require('node:os');
|
||||
const path = require('node:path');
|
||||
const { ScraperService } = require('../service');
|
||||
|
||||
test('status and watchdog read the checkpoint for each source layout', async t => {
|
||||
const root = await fs.mkdtemp(path.join(os.tmpdir(), 'mc-checkpoint-location-'));
|
||||
t.after(() => fs.rm(root, { recursive: true, force: true }));
|
||||
for (const [source, id, folder] of [
|
||||
['weebcentral', 'W1', '.mcscraper-work-W1'],
|
||||
['mangadex', 'D1', '.mcscraper-work-D1'],
|
||||
['mangapill', 'P1', '.mcscraper-work-mangapill-P1'],
|
||||
]) {
|
||||
const dir = path.join(root, folder);
|
||||
await fs.mkdir(dir);
|
||||
await fs.writeFile(path.join(dir, 'job.json'), JSON.stringify({
|
||||
status: 'downloading', publicationMode: 'incremental', jobCompleted: 3,
|
||||
total: 10, updated: '2026-10-14T12:00:00Z', current: { downloadedPages: 4 },
|
||||
}));
|
||||
const service = Object.create(ScraperService.prototype);
|
||||
service.libraryRoot = root;
|
||||
const job = await service.jobState({ source, seriesId: id, kind: 'download' });
|
||||
assert.equal(job.completed, 3, source);
|
||||
assert.equal(job.current.downloadedPages, 4, source);
|
||||
}
|
||||
});
|
||||
|
||||
test('daemon refuses recovery when the checkpoint cannot be read', async () => {
|
||||
const service = Object.create(ScraperService.prototype);
|
||||
service.state = { paused: false, currentIds: { mangapill: 'job' },
|
||||
queue: [{ id: 'job', source: 'mangapill', status: 'downloading' }] };
|
||||
service.jobState = async () => null;
|
||||
const result = await service.recover({ id: 'job', progressKey: '[0,0,"",0,""]' });
|
||||
assert.deepEqual(result, { changed: false });
|
||||
assert.equal(service.state.queue[0].stopReason, undefined);
|
||||
});
|
||||
Reference in new issue
Block a user