tus: remove multi-tab assumption + pass original err msg
Completely remove any assumptions of multi-tab uploading from server status (should have done it previously, but wanted to be conservative). This should make it less confusing to the user. The real issue still remains -- the upload is somehow locked at the backend. Also, when we override the error to present a user-friendly message to the user, pass the original error to the log (just in case it gives extra info).
This commit is contained in:
parent
238f6b2eda
commit
91d0eb30b8
1 changed files with 18 additions and 22 deletions
|
@ -78,29 +78,25 @@ export function makeResumableUploadRequest(
|
|||
const status = err.originalResponse ? err.originalResponse.getStatus() : 0;
|
||||
const errMsg = typeof err === 'string' ? err : err.message;
|
||||
|
||||
if (status === STATUS_CONFLICT) {
|
||||
window.store.dispatch(doUpdateUploadProgress({ guid, status: 'conflict' }));
|
||||
reject(new Error(`${status}: concurrent upload detected.`));
|
||||
} else {
|
||||
const errToLog =
|
||||
status === STATUS_LOCKED || errMsg === 'file currently locked'
|
||||
? 'File is locked. Try resuming after waiting a few minutes'
|
||||
: err;
|
||||
|
||||
window.store.dispatch(doUpdateUploadProgress({ guid, status: 'error' }));
|
||||
reject(
|
||||
// $FlowFixMe - flow's constructor for Error is incorrect.
|
||||
new Error(errToLog, {
|
||||
cause: {
|
||||
url: uploader.url,
|
||||
status,
|
||||
...(uploader._fingerprint ? { fingerprint: uploader._fingerprint } : {}),
|
||||
...(uploader._retryAttempt ? { retryAttempt: uploader._retryAttempt } : {}),
|
||||
...(uploader._offsetBeforeRetry ? { offsetBeforeRetry: uploader._offsetBeforeRetry } : {}),
|
||||
},
|
||||
})
|
||||
);
|
||||
let customErr;
|
||||
if (status === STATUS_LOCKED || errMsg === 'file currently locked') {
|
||||
customErr = 'File is locked. Try resuming after waiting a few minutes';
|
||||
}
|
||||
|
||||
window.store.dispatch(doUpdateUploadProgress({ guid, status: 'error' }));
|
||||
reject(
|
||||
// $FlowFixMe - flow's constructor for Error is incorrect.
|
||||
new Error(customErr || err, {
|
||||
cause: {
|
||||
url: uploader.url,
|
||||
status,
|
||||
...(uploader._fingerprint ? { fingerprint: uploader._fingerprint } : {}),
|
||||
...(uploader._retryAttempt ? { retryAttempt: uploader._retryAttempt } : {}),
|
||||
...(uploader._offsetBeforeRetry ? { offsetBeforeRetry: uploader._offsetBeforeRetry } : {}),
|
||||
...(customErr ? { original: errMsg } : {}),
|
||||
},
|
||||
})
|
||||
);
|
||||
},
|
||||
onProgress: (bytesUploaded, bytesTotal) => {
|
||||
const percentage = ((bytesUploaded / bytesTotal) * 100).toFixed(2);
|
||||
|
|
Loading…
Reference in a new issue