fix: if you have a resume-upload dialog that times out, upload is interrupted at next split-chunk time
Massimo Melina committed
Jan 15, 2025 at 16:02 UTC
7ae3bd13cca3b8187922a8dff0476a8704c3393f
1 file changed
+5
-2
frontend/src/uploadQueue.ts
+5
-2
@@ -177,12 +177,15 @@ export async function startUpload(toUpload: ToUpload, to: string, resume=0) {
177
preserveTempFile = true // this is affecting only split-uploads, because is undefined on first chunk (or no chunking)
178
if (size > toUpload.file.size) return
179
const {expires} = data
180
- const timeout = typeof expires !== 'number' ? 0
181
- : (Number(new Date(expires)) - Date.now()) / 1000
180
+ let timeout = typeof expires !== 'number' ? 0
181
+ : (Number(new Date(expires)) - Date.now())
182
+ if (timeout)
183
+ setTimeout(() => preserveTempFile = undefined, timeout) // the resumable is gone
184
closeLastDialog?.()
185
const cancelSub = subscribeKey(uploadState, 'partial', v =>
186
v >= size && closeLastDialog?.() ) // dismiss dialog as soon as we pass the threshold
187
const msg = t('confirm_resume', "Resume upload?") + ` (${formatPerc(size/toUpload.file.size)} = ${formatBytes(size)})`
188
+ timeout /= 1000 // needs seconds
189
const dialog = confirmDialog(msg, { timeout })
190
closeLastDialog = dialog.close
191
const confirmed = await dialog