@@ -414,6 +414,20 @@ class Unpack extends Parser {
414414 // check if a thing is there, and if so, try to clobber it
415415 [ CHECKFS ] ( entry ) {
416416 this [ PEND ] ( )
417+
418+ // if we are not creating a directory, and the path is in the dirCache,
419+ // then that means we are about to delete the directory we created
420+ // previously, and it is no longer going to be a directory, and neither
421+ // is any of its children.
422+ if ( entry . type !== 'Directory' ) {
423+ for ( const path of this . dirCache . keys ( ) ) {
424+ if ( path === entry . absolute ||
425+ path . indexOf ( entry . absolute + '/' ) === 0 ||
426+ path . indexOf ( entry . absolute + '\\' ) === 0 )
427+ this . dirCache . delete ( path )
428+ }
429+ }
430+
417431 this [ MKDIR ] ( path . dirname ( entry . absolute ) , this . dmode , er => {
418432 if ( er )
419433 return this [ ONERROR ] ( er , entry )
@@ -475,6 +489,15 @@ class UnpackSync extends Unpack {
475489 }
476490
477491 [ CHECKFS ] ( entry ) {
492+ if ( entry . type !== 'Directory' ) {
493+ for ( const path of this . dirCache . keys ( ) ) {
494+ if ( path === entry . absolute ||
495+ path . indexOf ( entry . absolute + '/' ) === 0 ||
496+ path . indexOf ( entry . absolute + '\\' ) === 0 )
497+ this . dirCache . delete ( path )
498+ }
499+ }
500+
478501 const er = this [ MKDIR ] ( path . dirname ( entry . absolute ) , this . dmode )
479502 if ( er )
480503 return this [ ONERROR ] ( er , entry )
0 commit comments