fix: (regression beta) upload: infinite loop trying to resume with delete_unfinished_uploads_after = 0
Massimo Melina committed
May 23, 2025 at 14:58 UTC
a83329823b988b51a78c46b86ae8156cc6beb7dc
1 file changed
+7
-2
frontend/src/uploadQueue.ts
+7
-2
@@ -1,5 +1,6 @@
1
import {
2
- HTTP_CONFLICT, HTTP_MESSAGES, HTTP_PAYLOAD_TOO_LARGE, UPLOAD_RESUMABLE, UPLOAD_REQUEST_STATUS, UPLOAD_RESUMABLE_HASH,
2
+ HTTP_CONFLICT, HTTP_MESSAGES, HTTP_PAYLOAD_TOO_LARGE, HTTP_RANGE_NOT_SATISFIABLE,
3
+ UPLOAD_RESUMABLE, UPLOAD_REQUEST_STATUS, UPLOAD_RESUMABLE_HASH,
4
buildUrlQueryString, dirname, getHFS, pathEncode, pendingPromise, prefix, randomId, tryJson, with_, wait, waitFor,
5
} from '@hfs/shared'
6
import { state } from './state'
@@ -90,7 +91,6 @@ export async function startUpload(toUpload: ToUpload, to: string, startingResume
91
console.debug('start upload', getFilePath(toUpload.file), startingResume)
92
let resuming = false
93
let preserveTempFile = undefined
93
- overrideStatus = 0
94
uploadState.uploading = toUpload
95
uploadState.progress = 0
96
userAborted = false
@@ -106,11 +106,16 @@ export async function startUpload(toUpload: ToUpload, to: string, startingResume
106
offset = Math.max(splitResume, lastWrittenReceived)
107
const req = currentReq = new XMLHttpRequest()
108
const requestIsOver = pendingPromise()
109
+ overrideStatus = 0
110
stuckSince = Date.now()
111
req.onloadend = async () => {
112
try {
113
currentReq = undefined
114
const status = overrideStatus || req.status
115
+ if (status === HTTP_RANGE_NOT_SATISFIABLE) {
116
+ lastWrittenReceived = 0
117
+ return
118
+ }
119
if (resuming) { // resuming requested
120
resuming = false // this behavior is only for once, for cancellation of the upload that is in the background while resume is confirmed
121
stopLooping = true