File tree 2 files changed +12
-3
lines changed
2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change 236
236
* @returns {boolean }
237
237
* @private
238
238
*/
239
- uploadNextChunk : function ( ) {
239
+ uploadNextChunk : function ( preventEvents ) {
240
240
// In some cases (such as videos) it's really handy to upload the first
241
241
// and last chunk of a file quickly; this let's the server check the file's
242
242
// metadata and determine if there's even a point in continuing.
290
290
return false ;
291
291
}
292
292
} ) ;
293
- if ( ! outstanding ) {
293
+ if ( ! outstanding && ! preventEvents ) {
294
294
// All chunks have been uploaded, complete
295
295
this . fire ( 'complete' ) ;
296
296
}
421
421
}
422
422
// Kick off the queue
423
423
this . fire ( 'uploadStart' ) ;
424
+ var started = false ;
424
425
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' ) ;
426
430
}
427
431
} ,
428
432
Original file line number Diff line number Diff line change @@ -125,6 +125,11 @@ describe('upload file', function() {
125
125
expect ( events [ 10 ] ) . toBe ( 'fileSuccess' ) ;
126
126
// Can be sync and async
127
127
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' ) ;
128
133
} ) ;
129
134
130
135
it ( 'should pause and resume file' , function ( ) {
You can’t perform that action at this time.
0 commit comments