@@ -3584,26 +3584,31 @@ angular
35843584 var uploadPath = ctx . path ;
35853585 var container = ctx . container ;
35863586 var type = ctx . type ;
3587+
3588+ var progressHandler = _ . throttle ( function ( ctx ) {
3589+ chunksProgress [ ctx . index ] = ctx . progress . loaded ;
3590+ var progression = chunksProgress . reduce ( function ( m , v ) { return m + v ; } , 0 ) / file . size ;
3591+ events . emit ( 'progress' , progression * 100 ) ;
3592+ } , 100 ) ;
3593+
35873594 var uploadChunksEvents = new EventEmitter ( ) ;
35883595 uploadChunksEvents . on ( 'start' , function ( ctx ) {
35893596 chunksProgress [ ctx . index ] = 0 ;
35903597 if ( ctx . cancel ) {
35913598 chunksCancel [ ctx . index ] = function ( ) { ctx . cancel ( ) ; } ;
35923599 }
3593- uploadChunksEvents . on ( 'progress' , function ( ctx ) {
3594- chunksProgress [ ctx . index ] = ctx . progress . loaded ;
3595- var progression = chunksProgress . reduce ( function ( m , v ) { return m + v ; } , 0 ) / file . size ;
3596- events . emit ( 'progress' , progression * 100 ) ;
3597- } ) ;
3600+ uploadChunksEvents . on ( 'progress' , progressHandler ) ;
35983601 } ) ;
35993602 uploadChunksEvents . on ( 'end' , function ( ) { fileOffset += chunkSize ; } ) ;
36003603 uploadChunksEvents . on ( 'end' , function ( ctx ) { delete chunksCancel [ ctx . index ] ; } ) ;
3604+
36013605 var result = Promise
36023606 . map (
36033607 chunks ( file , { chunkSize : chunkSize , fileOffset : fileOffset } ) ,
36043608 function ( v ) { return uploadChunk ( v . chunk , v . index , uploadId , uploadPath , uploadChunksEvents ) ; } ,
36053609 { concurrency : 3 }
36063610 ) ;
3611+
36073612 return result
36083613 . then ( function ( ) { return { uploadId : uploadId , uploadPath : uploadPath , container : container , type : type } ; } ) ;
36093614 } )
0 commit comments