@@ -34,9 +34,9 @@ module.exports = (files, dagService, source, cb) => {
3434 if ( splitted [ 0 ] === '' ) {
3535 splitted = splitted . slice ( 1 )
3636 }
37- var tmpTree = fileTree
37+ let tmpTree = fileTree
3838
39- for ( var i = 0 ; i < splitted . length ; i ++ ) {
39+ for ( let i = 0 ; i < splitted . length ; i ++ ) {
4040 if ( ! tmpTree [ splitted [ i ] ] ) {
4141 tmpTree [ splitted [ i ] ] = { }
4242 }
@@ -73,15 +73,12 @@ module.exports = (files, dagService, source, cb) => {
7373 // Once finished, add the result as a link to the dir node
7474 // If the value is not an object
7575 // add as a link to the dirNode
76-
77- let pendingWrites = 0
78-
7976 function traverse ( tree , path , done ) {
8077 const keys = Object . keys ( tree )
8178
8279 mapValues ( tree , ( node , key , cb ) => {
8380 if ( typeof node === 'object' && ! Buffer . isBuffer ( node ) ) {
84- traverse . call ( this , node , path ? `${ path } /${ key } ` : key , cb )
81+ traverse ( node , path ? `${ path } /${ key } ` : key , cb )
8582 } else {
8683 cb ( null , node )
8784 }
@@ -107,9 +104,7 @@ module.exports = (files, dagService, source, cb) => {
107104
108105 n . data = d . marshal ( )
109106
110- pendingWrites ++
111107 dagService . put ( n , ( err ) => {
112- pendingWrites --
113108 if ( err ) {
114109 source . push ( new Error ( 'failed to store dirNode' ) )
115110 } else if ( path ) {
@@ -124,10 +119,7 @@ module.exports = (files, dagService, source, cb) => {
124119 } )
125120 } )
126121 }
127-
128- if ( pendingWrites <= 0 ) {
129- finish ( )
130- }
122+ finish ( )
131123 } )
132124
133125 function finish ( ) {
0 commit comments