From e01c7a4fdef8e7b505fe5fb3d59016c94ad35577 Mon Sep 17 00:00:00 2001 From: Maya Date: Sun, 22 Mar 2026 01:01:02 +0300 Subject: [PATCH] feat: feedback for downloading zip if a file is larger than 2gb (i assume arraybuffer related) or has to be streamed, takes noticably longer to zip the file --- messages/en.json | 1 + src/lib/store/index.svelte.ts | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/messages/en.json b/messages/en.json index 3df9e3d..3cc258d 100644 --- a/messages/en.json +++ b/messages/en.json @@ -70,6 +70,7 @@ "panel": { "convert_all": "Convert all", "download_all": "Download all as .zip", + "download_all_toast": "Zipping {count} files ({size}MB) for download. This may take a while for larger files (which may be streamed).", "remove_all": "Remove all files", "set_all_to": "Set all to", "na": "N/A" diff --git a/src/lib/store/index.svelte.ts b/src/lib/store/index.svelte.ts index 54b5a89..0bc9611 100644 --- a/src/lib/store/index.svelte.ts +++ b/src/lib/store/index.svelte.ts @@ -400,6 +400,7 @@ class Files { public async downloadAll() { if (this.files.length === 0) return; + // eslint-disable-next-line @typescript-eslint/no-explicit-any const dlFiles: any[] = []; const filenames: string[] = []; @@ -419,6 +420,8 @@ class Files { filenames.push(file.file.name.replace(/\.[^/.]+$/, "") + to); } + let totalSize = 0; + for (let i = 0; i < this.files.length; i++) { const file = this.files[i]; const result = file.result; @@ -437,6 +440,7 @@ class Files { filename = `${nameWithoutExt} (${i + 1})${ext}`; } + totalSize += result.file.size; dlFiles.push({ name: filename, lastModified: Date.now(), @@ -445,7 +449,20 @@ class Files { } const { downloadZip } = await import("client-zip"); + const size = (totalSize / (1024 * 1024)).toFixed(2); + log( + ["files"], + `adding ${dlFiles.length} files into zip (size: ${size}MB)...`, + ); + ToastManager.add({ + type: "info", + message: m["convert.panel.download_all_toast"]({ + count: dlFiles.length, + size, + }), + }); const blob = await downloadZip(dlFiles, "converted.zip").blob(); + const url = URL.createObjectURL(blob); const settings = readSettings<{ filenameFormat?: string }>();