Merge pull request '发布切换等待正在准备的原图下载' (#30) from codex/download-release-drain-20261104 into main
This commit is contained in:
commit
73eb276e7f
@ -89,6 +89,6 @@ export function scheduleImageDownloadPreparation(id?: string) {
|
||||
worker.scanPending = false;
|
||||
}
|
||||
}
|
||||
}, { durable: true });
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@ -112,10 +112,11 @@ test("the preparation deadline cancels the source body as well as its headers",
|
||||
test("requested downloads are prioritized with two workers before scanning background assets", async () => {
|
||||
let active = 0; let maximum = 0; let scans = 0;
|
||||
const releases: Array<() => void> = [];
|
||||
const workRecords: Array<{ active: number; durable: number }> = [];
|
||||
const claimed: string[] = []; const saved: string[] = [];
|
||||
const bytes = Buffer.from("compatible PNG fixture");
|
||||
const worker = serverLoader({
|
||||
"@/lib/observability/active-work": { trackRuntimeWork: (execute: () => Promise<void>) => execute() },
|
||||
"node:fs": { writeFileSync: (_path: string, value: string) => workRecords.push(JSON.parse(value)), unlinkSync() {} },
|
||||
"./image-archive-db": {
|
||||
claimImageDownloadTask: async (id: string) => { claimed.push(id); return { id, targetUrl: `https://cdn.example/${id}.png`, metadata: {} }; },
|
||||
saveImageDownloadAsset: async (id: string) => saved.push(id),
|
||||
@ -127,6 +128,7 @@ test("requested downloads are prioritized with two workers before scanning backg
|
||||
})("lib/storage/image-download-preparation.ts");
|
||||
worker.scheduleImageDownloadPreparation("one"); worker.scheduleImageDownloadPreparation("two"); worker.scheduleImageDownloadPreparation("three");
|
||||
await expect.poll(() => active).toBe(2);
|
||||
expect(workRecords.at(-1)).toMatchObject({ active: 1, durable: 0 });
|
||||
expect(scans).toBe(0);
|
||||
releases.splice(0).forEach(release => release());
|
||||
await expect.poll(() => claimed.length).toBe(3);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user