diff --git a/apps/files/js/file-upload.js b/apps/files/js/file-upload.js index 6bee3c3bdc..824f6a1fd5 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