Detect concurrent uploads and stop it.
This commit is contained in:
parent
b6e9c7aabf
commit
2d3057d5cf
4 changed files with 27 additions and 5 deletions
|
@ -1303,6 +1303,7 @@
|
|||
"Retrying...": "Retrying...",
|
||||
"Uploading...": "Uploading...",
|
||||
"Creating...": "Creating...",
|
||||
"Stopped. Duplicate session detected.": "Stopped. Duplicate session detected.",
|
||||
"Use a URL": "Use a URL",
|
||||
"Edit Cover Image": "Edit Cover Image",
|
||||
"Cover Image": "Cover Image",
|
||||
|
|
|
@ -66,6 +66,8 @@ export default function WebUploadItem(props: Props) {
|
|||
return __('Retrying...');
|
||||
case 'error':
|
||||
return __('Failed.');
|
||||
case 'conflict':
|
||||
return __('Stopped. Duplicate session detected.');
|
||||
default:
|
||||
return status;
|
||||
}
|
||||
|
@ -130,7 +132,7 @@ export default function WebUploadItem(props: Props) {
|
|||
<div className="claim-upload__progress--label">lbry://{params.name}</div>
|
||||
<div className={'claim-upload__progress--outer card--inline'}>
|
||||
<div className={'claim-upload__progress--inner'} style={{ width: `${progress}%` }}>
|
||||
{resolveProgressStr()}
|
||||
<span className="claim-upload__progress--inner-text">{resolveProgressStr()}</span>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
|
|
|
@ -375,6 +375,15 @@
|
|||
.claim-upload__progress--inner {
|
||||
background: var(--color-primary-alt);
|
||||
padding: var(--spacing-xxs);
|
||||
height: 2.4rem;
|
||||
}
|
||||
|
||||
.claim-upload__progress--inner-text {
|
||||
position: absolute;
|
||||
width: 80%;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
@ -72,11 +72,21 @@ export function makeResumableUploadRequest(
|
|||
onShouldRetry: (err, retryAttempt, options) => {
|
||||
window.store.dispatch(doUpdateUploadProgress({ params, status: 'retry' }));
|
||||
const status = err.originalResponse ? err.originalResponse.getStatus() : 0;
|
||||
return !inStatusCategory(status, 400) || status === STATUS_CONFLICT || status === STATUS_LOCKED;
|
||||
return !inStatusCategory(status, 400);
|
||||
},
|
||||
onError: (error) => {
|
||||
window.store.dispatch(doUpdateUploadProgress({ params, status: 'error' }));
|
||||
reject(new Error(error));
|
||||
onError: (err) => {
|
||||
const status = err.originalResponse ? err.originalResponse.getStatus() : 0;
|
||||
if (status === STATUS_CONFLICT || status === STATUS_LOCKED) {
|
||||
window.store.dispatch(doUpdateUploadProgress({ params, status: 'conflict' }));
|
||||
reject(
|
||||
new Error(
|
||||
`${status}: concurrent upload detected. Uploading the same file from multiple tabs or windows is not allowed.`
|
||||
)
|
||||
);
|
||||
} else {
|
||||
window.store.dispatch(doUpdateUploadProgress({ params, status: 'error' }));
|
||||
reject(new Error(err));
|
||||
}
|
||||
},
|
||||
onProgress: (bytesUploaded, bytesTotal) => {
|
||||
const percentage = ((bytesUploaded / bytesTotal) * 100).toFixed(2);
|
||||
|
|
Loading…
Reference in a new issue