File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 443443 return uploading ;
444444 } ,
445445
446+ /**
447+ * should upload next chunk
448+ * @function
449+ * @returns {boolean|number }
450+ */
451+ _shouldUploadNext : function ( ) {
452+ var num = 0 ;
453+ var should = true ;
454+ var simultaneousUploads = this . opts . simultaneousUploads ;
455+ each ( this . files , function ( file ) {
456+ each ( file . chunks , function ( chunk ) {
457+ if ( chunk . status ( ) === 'uploading' ) {
458+ num ++ ;
459+ if ( num >= simultaneousUploads ) {
460+ should = false ;
461+ return false ;
462+ }
463+ }
464+ } ) ;
465+ } ) ;
466+ // if should is true then return uploading chunks's length
467+ return should && num ;
468+ } ,
469+
446470 /**
447471 * Start or resume uploading.
448472 * @function
449473 */
450474 upload : function ( ) {
451475 // Make sure we don't start too many uploads at once
452- if ( this . isUploading ( ) ) {
476+ var ret = this . _shouldUploadNext ( ) ;
477+ if ( ret === false ) {
453478 return ;
454479 }
455480 // Kick off the queue
456481 this . fire ( 'uploadStart' ) ;
457482 var started = false ;
458- for ( var num = 1 ; num <= this . opts . simultaneousUploads ; num ++ ) {
483+ for ( var num = 1 ; num <= this . opts . simultaneousUploads - ret ; num ++ ) {
459484 started = this . uploadNextChunk ( true ) || started ;
460485 }
461486 if ( ! started ) {
You can’t perform that action at this time.
0 commit comments