fix: (regression beta) upload-resume dialog was closed when background upload was split

Massimo Melina committed Sep 27, 2024 at 00:36 UTC fd218ae3d85f1b1f636a9384a7e0bb0266698549
1 file changed +4 -2
frontend/src/upload.ts
+4 -2
@@ -320,7 +320,8 @@ async function startUpload(toUpload: ToUpload, to: string, resume=0) {
320 finished.resolve()
321 if (req?.readyState !== 4) return
322 const status = overrideStatus || req.status
323 - closeLast?.()
323 + if (!partial) // if the upload ends here, the offer for resuming must stop
324 + closeLast?.()
325 if (resuming) { // resuming requested
326 resuming = false // this behavior is only for once, for cancellation of the upload that is in the background while resume is confirmed
327 stopLooping()
@@ -354,9 +355,10 @@ async function startUpload(toUpload: ToUpload, to: string, resume=0) {
355 let uploadPath = path(toUpload.file)
356 if (toUpload.name)
357 uploadPath = prefix('', dirname(uploadPath), '/') + toUpload.name
358 + const partial = splitSize && offset + splitSize < fullSize
359 req.open('PUT', to + pathEncode(uploadPath) + buildUrlQueryString({
360 notificationChannel,
359 - ...splitSize && offset + splitSize < fullSize && { partial: 'y' },
361 + ...partial && { partial: 'y' },
362 ...offset && { resume: String(offset) },
363 ...toUpload.comment && { comment: toUpload.comment },
364 ...with_(state.uploadOnExisting, x => x !== 'rename' && { existing: x }), // rename is the default