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
|
@ -576,7 +576,6 @@ OC.Uploader.prototype = _.extend({
|
||||||
* Clear uploads
|
* Clear uploads
|
||||||
*/
|
*/
|
||||||
clear: function() {
|
clear: function() {
|
||||||
this._uploads = {};
|
|
||||||
this._knownDirs = {};
|
this._knownDirs = {};
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
|
@ -595,6 +594,19 @@ OC.Uploader.prototype = _.extend({
|
||||||
return null;
|
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() {
|
showUploadCancelMessage: _.debounce(function() {
|
||||||
OC.Notification.show(t('files', 'Upload cancelled.'), {timeout : 7, type: 'error'});
|
OC.Notification.show(t('files', 'Upload cancelled.'), {timeout : 7, type: 'error'});
|
||||||
}, 500),
|
}, 500),
|
||||||
|
@ -959,6 +971,8 @@ OC.Uploader.prototype = _.extend({
|
||||||
}
|
}
|
||||||
self.log('fail', e, upload);
|
self.log('fail', e, upload);
|
||||||
|
|
||||||
|
self.removeUpload(upload);
|
||||||
|
|
||||||
if (data.textStatus === 'abort') {
|
if (data.textStatus === 'abort') {
|
||||||
self.showUploadCancelMessage();
|
self.showUploadCancelMessage();
|
||||||
} else if (status === 412) {
|
} else if (status === 412) {
|
||||||
|
@ -996,6 +1010,8 @@ OC.Uploader.prototype = _.extend({
|
||||||
var that = $(this);
|
var that = $(this);
|
||||||
self.log('done', e, upload);
|
self.log('done', e, upload);
|
||||||
|
|
||||||
|
self.removeUpload(upload);
|
||||||
|
|
||||||
var status = upload.getResponseStatus();
|
var status = upload.getResponseStatus();
|
||||||
if (status < 200 || status >= 300) {
|
if (status < 200 || status >= 300) {
|
||||||
// trigger fail handler
|
// trigger fail handler
|
||||||
|
|
Loading…
Reference in New Issue