Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions apps/files/js/file-upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,11 @@ OC.FileUpload = function(uploader, data) {
if (!data) {
throw 'Missing "data" argument in OC.FileUpload constructor';
}
var path = '';
var basePath = '';
if (this.uploader.fileList) {
path = OC.joinPaths(this.uploader.fileList.getCurrentDirectory(), this.getFile().name);
} else {
path = this.getFile().name;
basePath = this.uploader.fileList.getCurrentDirectory();
}
var path = OC.joinPaths(basePath, this.getFile().relativePath || '', this.getFile().name);
this.id = 'web-file-upload-' + md5(path) + '-' + (new Date()).getTime();
};
OC.FileUpload.CONFLICT_MODE_DETECT = 0;
Expand Down Expand Up @@ -622,7 +621,13 @@ OC.Uploader.prototype = _.extend({
* Clear uploads
*/
clear: function() {
this._uploads = {};
var remainingUploads = {};
_.each(this._uploads, function(upload, key) {
if (!upload.isDone) {
remainingUploads[key] = upload;
}
});
this._uploads = remainingUploads;
this._knownDirs = {};
},
/**
Expand Down Expand Up @@ -1092,6 +1097,7 @@ OC.Uploader.prototype = _.extend({
var upload = self.getUpload(data);
var that = $(this);
self.log('done', e, upload);
upload.isDone = true;

var status = upload.getResponseStatus();
if (status < 200 || status >= 300) {
Expand Down
18 changes: 0 additions & 18 deletions apps/files/js/upload.js

This file was deleted.

10 changes: 10 additions & 0 deletions apps/files/tests/js/fileUploadSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,16 @@ describe('OC.Upload tests', function() {
expect(upload).toBeDefined();
expect(upload.getFileName()).toEqual('test.txt');
});
it('clear leaves pending uploads', function() {
uploader._uploads = {
'abc': {name: 'a job well done.txt', isDone: true},
'def': {name: 'whatevs.txt'}
};

uploader.clear();

expect(uploader._uploads).toEqual({'def': {name: 'whatevs.txt'}});
});
});
describe('Upload conflicts', function() {
var conflictDialogStub;
Expand Down