Resume the preview rebuild where a restart left it.
The job only lived in memory, so every deploy discarded hours of proxy work and the next run started at the first photo. Mirror progress to the storage root after each photo and pick the pending ids back up on boot. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
This commit is contained in:
@@ -63,6 +63,22 @@ describe('preview rebuild job', () => {
|
||||
expect(job.snapshot().errors).toEqual([]);
|
||||
});
|
||||
|
||||
it('reports progress and what is still pending after each photo', async () => {
|
||||
const steps = [];
|
||||
const job = startPreviewRebuild({
|
||||
targets: [{ id: 'a' }, { id: 'b' }, { id: 'c' }],
|
||||
regenerate: async () => ({ sidecar: false }),
|
||||
onProgress: (snapshot, pending) =>
|
||||
steps.push({ done: snapshot.done, pending: pending.map((photo) => photo.id) }),
|
||||
});
|
||||
await job.finished;
|
||||
expect(steps).toEqual([
|
||||
{ done: 1, pending: ['b', 'c'] },
|
||||
{ done: 2, pending: ['c'] },
|
||||
{ done: 3, pending: [] },
|
||||
]);
|
||||
});
|
||||
|
||||
it('finishes immediately when there is nothing to rebuild', async () => {
|
||||
const job = startPreviewRebuild({ targets: [], regenerate: async () => ({ sidecar: false }) });
|
||||
await job.finished;
|
||||
|
||||
Reference in New Issue
Block a user