From 8c7ca174bc375335e8caca855e649a255a790bfc Mon Sep 17 00:00:00 2001 From: WuYongJie <549727955@qq.com> Date: Wed, 4 Nov 2026 18:06:27 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=91=E5=B8=83=E5=88=87=E6=8D=A2=E7=AD=89?= =?UTF-8?q?=E5=BE=85=E6=AD=A3=E5=9C=A8=E5=87=86=E5=A4=87=E7=9A=84=E5=8E=9F?= =?UTF-8?q?=E5=9B=BE=E4=B8=8B=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/storage/image-download-preparation.ts | 2 +- tests/routes/canvas-download-recovery.test.ts | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/storage/image-download-preparation.ts b/lib/storage/image-download-preparation.ts index 46da2d450..bb179fc9d 100644 --- a/lib/storage/image-download-preparation.ts +++ b/lib/storage/image-download-preparation.ts @@ -89,6 +89,6 @@ export function scheduleImageDownloadPreparation(id?: string) { worker.scanPending = false; } } - }, { durable: true }); + }); }); } diff --git a/tests/routes/canvas-download-recovery.test.ts b/tests/routes/canvas-download-recovery.test.ts index 6468113d0..ff086d343 100644 --- a/tests/routes/canvas-download-recovery.test.ts +++ b/tests/routes/canvas-download-recovery.test.ts @@ -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) => 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); -- 2.47.2