diff options
author | Simon Birnbach <simon@simon-birnbach.de> | 2012-04-15 23:52:36 +0200 |
---|---|---|
committer | Simon Birnbach <simon@simon-birnbach.de> | 2012-04-15 23:52:36 +0200 |
commit | 965a8ba2c60eb04e2f65a4ace215113ac61f7c98 (patch) | |
tree | 38292db21226c43c41ce68eb2ccd638d457e678d /files/js/files.js | |
parent | 8e27b725ba2aa26cb9037b44b18ff800649017b1 (diff) | |
download | nextcloud-server-965a8ba2c60eb04e2f65a4ace215113ac61f7c98.tar.gz nextcloud-server-965a8ba2c60eb04e2f65a4ace215113ac61f7c98.zip |
Fixed cancelling of uploads and wrong merge conflict resolution
Diffstat (limited to 'files/js/files.js')
-rw-r--r-- | files/js/files.js | 42 |
1 files changed, 33 insertions, 9 deletions
diff --git a/files/js/files.js b/files/js/files.js index a7a4d3077c1..56fff753737 100644 --- a/files/js/files.js +++ b/files/js/files.js @@ -9,13 +9,20 @@ Files={ return false; }, cancelUploads:function() { - $.each(uploadingFiles,function(index,file){ - file.abort(); + $.each(uploadingFiles,function(index,file) { + if(typeof file['abort'] === 'function') { + file.abort(); + var filename = $('tr').filterAttr('data-file',index); + filename.hide(); + filename.find('input[type="checkbox"]').removeAttr('checked'); + filename.removeClass('selected'); + } else { + $.each(file,function(i,f) { + f.abort(); + delete file[i]; + }); + } delete uploadingFiles[index]; - var filename = $('tr').filterAttr('data-file',index); - filename.hide(); - filename.find('input[type="checkbox"]').removeAttr('checked'); - filename.removeClass('selected'); }); procesSelection(); } @@ -206,8 +213,9 @@ $(document).ready(function() { }else{ if($.support.xhrFileUpload) { for(var i=0;i<files.length;i++){ + var fileName = files[i].name var dropTarget = $(e.originalEvent.target).closest('tr'); - if(dropTarget && dropTarget.attr('data-type') === 'dir') { + if(dropTarget && dropTarget.attr('data-type') === 'dir') { // drag&drop upload to folder var dirName = dropTarget.attr('data-file') var jqXHR = $('.file_upload_start').fileupload('send', {files: files[i], formData: function(form) { @@ -222,7 +230,7 @@ $(document).ready(function() { $('#notification').fadeIn(); } var file=response[0]; - delete uploadingFiles[file.name]; + delete uploadingFiles[dirName][file.name]; var currentUploads = parseInt(uploadtext.attr('currentUploads')); currentUploads -= 1; uploadtext.attr('currentUploads', currentUploads); @@ -238,12 +246,28 @@ $(document).ready(function() { }) .error(function(jqXHR, textStatus, errorThrown) { if(errorThrown === 'abort') { + var currentUploads = parseInt(uploadtext.attr('currentUploads')); + currentUploads -= 1; + uploadtext.attr('currentUploads', currentUploads); + if(currentUploads === 0) { + var img = OC.imagePath('core', 'filetypes/folder.png'); + var tr=$('tr').filterAttr('data-file',dirName); + tr.find('td.filename').attr('style','background-image:url('+img+')'); + uploadtext.text(''); + uploadtext.hide(); + } else { + uploadtext.text(currentUploads + ' files uploading') + } $('#notification').hide(); $('#notification').text(t('files', 'Upload cancelled.')); $('#notification').fadeIn(); } }); - uploadingFiles[dirName+"/"+files[i].name] = jqXHR; + //TODO test with filenames containing slashes + if(uploadingFiles[dirName] === undefined) { + uploadingFiles[dirName] = {}; + } + uploadingFiles[dirName][fileName] = jqXHR; } else { var jqXHR = $('.file_upload_start').fileupload('send', {files: files[i]}) .success(function(result, textStatus, jqXHR) { |