diff --git a/src/app/api/lightbox/bulk-download/route.ts b/src/app/api/lightbox/bulk-download/route.ts index 40f48ee..062500b 100644 --- a/src/app/api/lightbox/bulk-download/route.ts +++ b/src/app/api/lightbox/bulk-download/route.ts @@ -130,7 +130,11 @@ export async function POST(request: NextRequest) { } const passThrough = new PassThrough(); - const archive = archiver('zip', { zlib: { level: 0 } }); + // archiver v8 exports class constructors ({ ZipArchive, ... }), not a + // callable. The old `archiver('zip', opts)` form throws TypeError at + // runtime — which was masked until the membership fix populated the map + // and this line was actually reached (before, the route 404'd early). + const archive = new archiver.ZipArchive({ zlib: { level: 0 } }); archive.pipe(passThrough); // Start appending files asynchronously diff --git a/src/app/redaktion/leuchtkasten/DownloadLightboxForm.tsx b/src/app/redaktion/leuchtkasten/DownloadLightboxForm.tsx index 7edd505..30a5d93 100644 --- a/src/app/redaktion/leuchtkasten/DownloadLightboxForm.tsx +++ b/src/app/redaktion/leuchtkasten/DownloadLightboxForm.tsx @@ -23,7 +23,18 @@ export function DownloadLightboxForm({ assetIds }: { assetIds: string[] }) { }); if (!response.ok) { - throw new Error("Download fehlgeschlagen"); + // Surface the server's error code instead of a generic message so the + // real cause (e.g. IMMICH_UNAVAILABLE, REQUEST_FAILED) is visible in the + // browser console — the bulk handler maps UsageAccountingError to codes. + let code: string | undefined; + try { + code = (await response.clone().json()).code; + } catch { + /* non-JSON body (e.g. plain 500) — code stays undefined */ + } + const status = response.status; + console.error("[bulk-download] server error:", { status, code }); + throw new Error(`Download fehlgeschlagen (${status}${code ? ` ${code}` : ""})`); } // Download the ZIP file @@ -36,12 +47,13 @@ export function DownloadLightboxForm({ assetIds }: { assetIds: string[] }) { a.click(); document.body.removeChild(a); URL.revokeObjectURL(url); - + dialogRef.current?.close(); setPurpose(""); router.refresh(); // Refresh to update usage history } catch (err) { - alert("Es gab einen Fehler beim Bulk-Download. Bitte versuche es später erneut."); + const message = err instanceof Error ? err.message : "Download fehlgeschlagen"; + alert(`Bulk-Download fehlgeschlagen: ${message}`); console.error(err); } finally { setLoading(false);