11/*!
22 * Uploader - Uploader library implements html5 file upload and provides multiple simultaneous, stable, fault tolerant and resumable uploads
3- * @version v0.1.0
3+ * @version v0.1.1
44 * @author dolymood <dolymood@gmail.com>
55 * @link https://github.com/simple-uploader/Uploader
66 * @license MIT
@@ -352,7 +352,7 @@ var event = _dereq_('./event')
352352var File = _dereq_ ( './file' )
353353var Chunk = _dereq_ ( './chunk' )
354354
355- var version = '0.1.0 '
355+ var version = '0.1.1 '
356356
357357// ie10+
358358var ie10plus = window . navigator . msPointerEnabled
@@ -391,7 +391,7 @@ function Uploader (opts) {
391391 return
392392 }
393393 this . supportDirectory = supportDirectory
394- this . filePaths = { }
394+ utils . defineNonEnumerable ( this , ' filePaths' , { } )
395395 this . opts = utils . extend ( { } , Uploader . defaults , opts || { } )
396396
397397 File . call ( this , this )
@@ -482,6 +482,8 @@ utils.extend(Uploader.prototype, {
482482 _file . uniqueIdentifier = uniqueIdentifier
483483 if ( this . _trigger ( 'fileAdded' , _file , evt ) ) {
484484 _files . push ( _file )
485+ } else {
486+ File . prototype . removeFile . call ( this , _file )
485487 }
486488 }
487489 }
@@ -496,6 +498,10 @@ utils.extend(Uploader.prototype, {
496498 this . files . push ( file )
497499 } , this )
498500 this . _trigger ( 'filesSubmitted' , _files , newFileList , evt )
501+ } else {
502+ utils . each ( newFileList , function ( file ) {
503+ File . prototype . removeFile . call ( this , file )
504+ } , this )
499505 }
500506 } ,
501507
@@ -1267,20 +1273,22 @@ utils.extend(File.prototype, {
12671273 } ,
12681274
12691275 _removeFile : function ( file ) {
1270- ! file . isFolder && utils . each ( this . files , function ( f , i ) {
1271- if ( f === file ) {
1272- this . files . splice ( i , 1 )
1273- file . abort ( )
1274- var parent = file . parent
1275- var newParent
1276- while ( parent && parent !== this ) {
1277- newParent = parent . parent
1278- parent . _removeFile ( file )
1279- parent = newParent
1276+ if ( ! file . isFolder ) {
1277+ utils . each ( this . files , function ( f , i ) {
1278+ if ( f === file ) {
1279+ this . files . splice ( i , 1 )
1280+ return false
12801281 }
1281- return false
1282+ } , this )
1283+ file . abort ( )
1284+ var parent = file . parent
1285+ var newParent
1286+ while ( parent && parent !== this ) {
1287+ newParent = parent . parent
1288+ parent . _removeFile ( file )
1289+ parent = newParent
12821290 }
1283- } , this )
1291+ }
12841292 file . parent === this && utils . each ( this . fileList , function ( f , i ) {
12851293 if ( f === file ) {
12861294 this . fileList . splice ( i , 1 )
0 commit comments