Merge pull request #9245 from nextcloud/fix-race-condition-when-preparing-upload-folder
Fix race condition when preparing upload folder
This commit is contained in:
commit
3ff041f86d
1 changed files with 17 additions and 1 deletions
|
@ -576,7 +576,6 @@ OC.Uploader.prototype = _.extend({
|
|||
* Clear uploads
|
||||
*/
|
||||
clear: function() {
|
||||
this._uploads = {};
|
||||
this._knownDirs = {};
|
||||
},
|
||||
/**
|
||||
|
@ -595,6 +594,19 @@ OC.Uploader.prototype = _.extend({
|
|||
return null;
|
||||
},
|
||||
|
||||
/**
|
||||
* Removes an upload from the list of known uploads.
|
||||
*
|
||||
* @param {OC.FileUpload} upload the upload to remove.
|
||||
*/
|
||||
removeUpload: function(upload) {
|
||||
if (!upload || !upload.data || !upload.data.uploadId) {
|
||||
return;
|
||||
}
|
||||
|
||||
delete this._uploads[upload.data.uploadId];
|
||||
},
|
||||
|
||||
showUploadCancelMessage: _.debounce(function() {
|
||||
OC.Notification.show(t('files', 'Upload cancelled.'), {timeout : 7, type: 'error'});
|
||||
}, 500),
|
||||
|
@ -959,6 +971,8 @@ OC.Uploader.prototype = _.extend({
|
|||
}
|
||||
self.log('fail', e, upload);
|
||||
|
||||
self.removeUpload(upload);
|
||||
|
||||
if (data.textStatus === 'abort') {
|
||||
self.showUploadCancelMessage();
|
||||
} else if (status === 412) {
|
||||
|
@ -996,6 +1010,8 @@ OC.Uploader.prototype = _.extend({
|
|||
var that = $(this);
|
||||
self.log('done', e, upload);
|
||||
|
||||
self.removeUpload(upload);
|
||||
|
||||
var status = upload.getResponseStatus();
|
||||
if (status < 200 || status >= 300) {
|
||||
// trigger fail handler
|
||||
|
|
Loading…
Reference in a new issue