@@ -322,26 +322,34 @@ OC.FileUpload.prototype = {
322322 ) ;
323323 } ,
324324
325+ _delete : function ( ) {
326+ var self = this ;
327+ if ( this . data . isChunked ) {
328+ this . _deleteChunkFolder ( )
329+ }
330+ this . deleteUpload ( ) ;
331+ } ,
332+
325333 /**
326334 * Abort the upload
327335 */
328336 abort : function ( ) {
329- if ( this . data . isChunked ) {
330- this . _deleteChunkFolder ( ) ;
337+ var self = this ;
338+ if ( this . aborted ) {
339+ return
331340 }
332- this . data . abort ( ) ;
333- this . deleteUpload ( ) ;
334341 this . aborted = true ;
342+ this . _delete ( ) ;
335343 } ,
336344
337345 /**
338346 * Fail the upload
339347 */
340348 fail : function ( ) {
341- this . deleteUpload ( ) ;
342- if ( this . data . isChunked ) {
343- this . _deleteChunkFolder ( ) ;
349+ if ( this . aborted ) {
350+ return
344351 }
352+ this . _delete ( ) ;
345353 } ,
346354
347355 /**
@@ -679,7 +687,13 @@ OC.Uploader.prototype = _.extend({
679687 return ;
680688 }
681689
682- delete this . _uploads [ upload . data . uploadId ] ;
690+ // defer as some calls/chunks might still be busy failing, so we need
691+ // the upload info there still
692+ var self = this ;
693+ var uploadId = upload . data . uploadId ;
694+ window . setTimeout ( function ( ) {
695+ delete self . _uploads [ uploadId ] ;
696+ } , 5000 )
683697 } ,
684698
685699 showUploadCancelMessage : _ . debounce ( function ( ) {
@@ -905,6 +919,7 @@ OC.Uploader.prototype = _.extend({
905919 if ( $uploadEl . exists ( ) ) {
906920 this . progressBar . on ( 'cancel' , function ( ) {
907921 self . cancelUploads ( ) ;
922+ self . showUploadCancelMessage ( ) ;
908923 } ) ;
909924
910925 this . fileUploadParam = {
@@ -1075,14 +1090,18 @@ OC.Uploader.prototype = _.extend({
10751090 var upload = self . getUpload ( data ) ;
10761091 var status = null ;
10771092 if ( upload ) {
1093+ if ( upload . aborted ) {
1094+ // uploads might fail with errors from the server when aborted
1095+ return
1096+ }
10781097 status = upload . getResponseStatus ( ) ;
10791098 }
10801099 self . log ( 'fail' , e , upload ) ;
10811100
10821101 self . removeUpload ( upload ) ;
10831102
10841103 if ( data . textStatus === 'abort' || data . errorThrown === 'abort' ) {
1085- self . showUploadCancelMessage ( ) ;
1104+ return
10861105 } else if ( status === 412 ) {
10871106 // file already exists
10881107 self . showConflict ( upload ) ;
@@ -1283,6 +1302,10 @@ OC.Uploader.prototype = _.extend({
12831302 fileupload . on ( 'fileuploadchunksend' , function ( e , data ) {
12841303 // modify the request to adjust it to our own chunking
12851304 var upload = self . getUpload ( data ) ;
1305+ if ( ! upload ) {
1306+ // likely cancelled
1307+ return
1308+ }
12861309 var range = data . contentRange . split ( ' ' ) [ 1 ] ;
12871310 var chunkId = range . split ( '/' ) [ 0 ] . split ( '-' ) [ 0 ] ;
12881311 data . url = OC . getRootPath ( ) +
@@ -1317,6 +1340,10 @@ OC.Uploader.prototype = _.extend({
13171340
13181341 self . trigger ( 'done' , e , upload ) ;
13191342 } ) . fail ( function ( status , response ) {
1343+ if ( upload . aborted ) {
1344+ return
1345+ }
1346+
13201347 var message = response . message ;
13211348 if ( status === 507 ) {
13221349 // not enough space
0 commit comments