summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@users.noreply.github.com>2018-04-23 08:50:16 +0200
committerGitHub <noreply@github.com>2018-04-23 08:50:16 +0200
commit3ff041f86d936524674d2def257ddc4b15a2c105 (patch)
tree5e12e377520456dc5267f57b747d09040bb8ceba /apps
parenta80fcf177bdc9c8be79f20c4102af2a8f9016ca8 (diff)
parent375a55b0ad28e66536919f9fd7b48e2a1d823a6d (diff)
downloadnextcloud-server-3ff041f86d936524674d2def257ddc4b15a2c105.tar.gz
nextcloud-server-3ff041f86d936524674d2def257ddc4b15a2c105.zip
Merge pull request #9245 from nextcloud/fix-race-condition-when-preparing-upload-folder
Fix race condition when preparing upload folder
Diffstat (limited to 'apps')
-rw-r--r--apps/files/js/file-upload.js18
1 files changed, 17 insertions, 1 deletions
diff --git a/apps/files/js/file-upload.js b/apps/files/js/file-upload.js
index 6bee3c3bdc2..824f6a1fd56 100644
--- a/apps/files/js/file-upload.js
+++ b/apps/files/js/file-upload.js
@@ -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