mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-07-07 09:51:37 +00:00
Commit 4: UI Progress & Frontend Error Handling
This commit is contained in:
parent
2ab36b42df
commit
9ac3dae265
1 changed files with 31 additions and 7 deletions
|
|
@ -366,13 +366,37 @@ export default {
|
|||
chunkForm.set('folder', this.selectedFolderId)
|
||||
chunkForm.set('chunk', chunk)
|
||||
|
||||
let retryCount = 0
|
||||
const maxRetries = 1
|
||||
let chunkSuccess = false
|
||||
|
||||
while (retryCount <= maxRetries && !chunkSuccess) {
|
||||
try {
|
||||
// Await each chunk sequentially
|
||||
await this.$axios.$post('/api/upload/chunk', chunkForm)
|
||||
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) {
|
||||
console.error(`Failed to upload chunk ${chunkIndex} for ${file.name}`, 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 // Stop uploading chunks if one fails
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!chunkSuccess) {
|
||||
break // Break the outer chunk loop if retries exhausted
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue