Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable13] Fix race condition when preparing upload folder #9454

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 17 additions & 1 deletion apps/files/js/file-upload.js
Expand Up @@ -576,7 +576,6 @@ OC.Uploader.prototype = _.extend({
* Clear uploads
*/
clear: function() {
this._uploads = {};
this._knownDirs = {};
},
/**
Expand All @@ -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),
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down