From dcbbe04eebb752cc431ef1f434b36833bc6bd54f Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Thu, 3 Sep 2026 12:12:31 -0500 Subject: [PATCH] fix: allow each chunk to process separate and report final status based on all chunks uploading successfully --- src/wwwroot/index.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/wwwroot/index.js b/src/wwwroot/index.js index 367337b..da12b4b 100644 --- a/src/wwwroot/index.js +++ b/src/wwwroot/index.js @@ -117,7 +117,7 @@ document.addEventListener("DOMContentLoaded", () => { : "Uploading..."; const MAX_CONCURRENCY = 4; - let uploadFailed = false; + let failedChunksCount = 0; async function worker() { while (pendingIndices.length > 0 && !uploadFailed) { @@ -149,7 +149,9 @@ document.addEventListener("DOMContentLoaded", () => { }); if (!response.ok) { - throw new Error(`Chunk ${index} failed`); + throw new Error( + `Chunk ${index} failed with status ${response.status}`, + ); } chunkCheckmark?.classList.remove("hidden"); @@ -159,8 +161,8 @@ document.addEventListener("DOMContentLoaded", () => { chunkStatus.innerText = "Succeeded"; } } catch (err) { - console.err(err); - uploadFailed = true; + console.error(`Chunk ${index} failed:`, err); + failedChunksCount++; chunkRedX?.classList.remove("hidden"); chunkSpinner?.classList.add("hidden"); @@ -181,11 +183,10 @@ document.addEventListener("DOMContentLoaded", () => { await Promise.all(workers); - if (uploadFailed) { + if (failedChunksCount > 0) { fileSpinnerElement?.classList.add("hidden"); fileRedXElement?.classList.remove("hidden"); - fileStatusElement.innerText = - "Upload paused/failed. Select file again to resume."; + fileStatusElement.innerText = `${failedChunksCount} chunk(s) failed. Select file again to resume.`; return; }