File tree Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change 236236 * @returns {boolean }
237237 * @private
238238 */
239- uploadNextChunk : function ( ) {
239+ uploadNextChunk : function ( preventEvents ) {
240240 // In some cases (such as videos) it's really handy to upload the first
241241 // and last chunk of a file quickly; this let's the server check the file's
242242 // metadata and determine if there's even a point in continuing.
290290 return false ;
291291 }
292292 } ) ;
293- if ( ! outstanding ) {
293+ if ( ! outstanding && ! preventEvents ) {
294294 // All chunks have been uploaded, complete
295295 this . fire ( 'complete' ) ;
296296 }
421421 }
422422 // Kick off the queue
423423 this . fire ( 'uploadStart' ) ;
424+ var started = false ;
424425 for ( var num = 1 ; num <= this . opts . simultaneousUploads ; num ++ ) {
425- this . uploadNextChunk ( ) ;
426+ started = this . uploadNextChunk ( true ) || started ;
427+ }
428+ if ( ! started ) {
429+ this . fire ( 'complete' ) ;
426430 }
427431 } ,
428432
Original file line number Diff line number Diff line change @@ -125,6 +125,11 @@ describe('upload file', function() {
125125 expect ( events [ 10 ] ) . toBe ( 'fileSuccess' ) ;
126126 // Can be sync and async
127127 expect ( events [ 11 ] ) . toBe ( 'complete' ) ;
128+
129+ resumable . upload ( ) ;
130+ expect ( events . length ) . toBe ( 14 ) ;
131+ expect ( events [ 12 ] ) . toBe ( 'uploadStart' ) ;
132+ expect ( events [ 13 ] ) . toBe ( 'complete' ) ;
128133 } ) ;
129134
130135 it ( 'should pause and resume file' , function ( ) {
You can’t perform that action at this time.
0 commit comments