Skip to content

Commit

Permalink
Merge pull request #35134 from owncloud/fix-upload-cancel-issue-relea…
Browse files Browse the repository at this point in the history
…se-10.2.0

[10.2.0] Backport of Aborted uploads are not cleared properly
  • Loading branch information
Vincent Petry authored May 2, 2019
2 parents 5c9e26c + 5111ea7 commit c515df5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion apps/files/js/file-upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,7 @@ OC.Uploader.prototype = _.extend({
this.log('canceling uploads');
jQuery.each(this._uploads, function(i, upload) {
upload.abort();
upload.aborted = true;
});
this.clear();
},
Expand All @@ -691,7 +692,7 @@ OC.Uploader.prototype = _.extend({
clear: function() {
var remainingUploads = {};
_.each(this._uploads, function(upload, key) {
if (!upload.isDone) {
if (!upload.isDone && !upload.aborted) {
remainingUploads[key] = upload;
}
});
Expand Down
4 changes: 3 additions & 1 deletion apps/files/tests/js/fileUploadSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,13 @@ describe('OC.Upload tests', function() {
it('clear leaves pending uploads', function() {
uploader._uploads = {
'abc': {name: 'a job well done.txt', isDone: true},
'def': {name: 'whatevs.txt'}
'def': {name: 'whatevs.txt'},
'ghi': {name: 'aborted.txt', aborted: true}
};

uploader.clear();

//This does verify that aborted upload(s) will not be available in the _uploads
expect(uploader._uploads).toEqual({'def': {name: 'whatevs.txt'}});
});
});
Expand Down

0 comments on commit c515df5

Please sign in to comment.