From 9ac3dae265e4bb89b7259957f38e75e2dc6bc822 Mon Sep 17 00:00:00 2001 From: Josh Roskos Date: Sat, 16 May 2026 21:10:42 -0500 Subject: [PATCH] Commit 4: UI Progress & Frontend Error Handling --- client/pages/upload/index.vue | 38 ++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/client/pages/upload/index.vue b/client/pages/upload/index.vue index e4655dc75..49bb82dda 100644 --- a/client/pages/upload/index.vue +++ b/client/pages/upload/index.vue @@ -366,13 +366,37 @@ export default { chunkForm.set('folder', this.selectedFolderId) chunkForm.set('chunk', chunk) - try { - // Await each chunk sequentially - await this.$axios.$post('/api/upload/chunk', chunkForm) - } catch (error) { - console.error(`Failed to upload chunk ${chunkIndex} for ${file.name}`, error) - allFilesSuccessful = false - break // Stop uploading chunks if one fails + let retryCount = 0 + const maxRetries = 1 + let chunkSuccess = false + + while (retryCount <= maxRetries && !chunkSuccess) { + try { + const config = { + onUploadProgress: (progressEvent) => { + if (progressEvent.lengthComputable) { + // Calculate overall progress for this specific file + const totalLoaded = chunkIndex * CHUNK_SIZE + progressEvent.loaded + this.updateItemCardProgress(item.index, { loaded: totalLoaded, total: file.size }) + } + } + } + + await this.$axios.$post('/api/upload/chunk', chunkForm, config) + chunkSuccess = true + } catch (error) { + retryCount++ + console.error(`Failed to upload chunk ${chunkIndex} for ${file.name} (Attempt ${retryCount})`, error) + if (retryCount > maxRetries) { + this.$toast.error(`Failed to upload part of ${file.name}. Upload aborted.`) + allFilesSuccessful = false + break + } + } + } + + if (!chunkSuccess) { + break // Break the outer chunk loop if retries exhausted } } }