From eef8351d384796ce274bb7684bed3ac718b9bc5b Mon Sep 17 00:00:00 2001 From: vycdev2 <125471328+vycdev2@users.noreply.github.com> Date: Wed, 22 Jul 2026 07:10:02 +0000 Subject: [PATCH] fix: reject failed attachment downloads --- src/storage/images.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/storage/images.ts b/src/storage/images.ts index 7e10ee9..bac9c02 100644 --- a/src/storage/images.ts +++ b/src/storage/images.ts @@ -7,6 +7,12 @@ export async function downloadAttachment( filename: string, ): Promise { const response = await fetch(url); + if (!response.ok) { + throw new Error( + `Failed to download attachment: HTTP ${response.status} ${response.statusText}`, + ); + } + const buffer = Buffer.from(await response.arrayBuffer()); const filePath = path.join(IMAGES_DIR, filename); fs.writeFileSync(filePath, buffer);