TUS: handle remaining locked file error messages

This commit is contained in:
infinite-persistence 2021-11-23 11:23:05 +08:00
parent 605a8f371d
commit eb83a834a1
No known key found for this signature in database
GPG key ID: B9C3252EDC3D0AA0

View file

@ -76,13 +76,12 @@ export function makeResumableUploadRequest(
}, },
onError: (err) => { onError: (err) => {
const status = err.originalResponse ? err.originalResponse.getStatus() : 0; const status = err.originalResponse ? err.originalResponse.getStatus() : 0;
if (status === STATUS_CONFLICT || status === STATUS_LOCKED) { const errMsg = typeof err === 'string' ? err : err.message;
if (status === STATUS_CONFLICT || status === STATUS_LOCKED || errMsg === 'file currently locked') {
window.store.dispatch(doUpdateUploadProgress({ params, status: 'conflict' })); window.store.dispatch(doUpdateUploadProgress({ params, status: 'conflict' }));
reject( // prettier-ignore
new Error( reject(new Error(`${status}: concurrent upload detected. Uploading the same file from multiple tabs or windows is not allowed.`));
`${status}: concurrent upload detected. Uploading the same file from multiple tabs or windows is not allowed.`
)
);
} else { } else {
window.store.dispatch(doUpdateUploadProgress({ params, status: 'error' })); window.store.dispatch(doUpdateUploadProgress({ params, status: 'error' }));
reject(new Error(err)); reject(new Error(err));