File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1036,20 +1036,23 @@ async function preflightSnapshotMutations(
10361036 root : string ,
10371037 plan : { deletes : string [ ] ; writes : Array < { target : string ; content : Buffer } > } ,
10381038) {
1039+ const deletePaths = new Set ( plan . deletes ) ;
10391040 for ( const target of plan . deletes ) {
10401041 await assertNoSymlinkParents ( root , target ) ;
10411042 }
10421043 for ( const item of plan . writes ) {
1043- await prepareSnapshotWrite ( root , item . target ) ;
1044+ await prepareSnapshotWrite ( root , item . target , deletePaths ) ;
10441045 }
10451046}
10461047
1047- async function prepareSnapshotWrite ( root : string , target : string ) {
1048+ async function prepareSnapshotWrite ( root : string , target : string , deletePaths : Set < string > ) {
10481049 await ensureSafeDirectory ( root , path . dirname ( target ) ) ;
10491050 try {
10501051 const stat = await fs . lstat ( target ) ;
10511052 if ( stat . isSymbolicLink ( ) ) throw new Error ( `Refusing to overwrite symlink during snapshot apply: ${ target } ` ) ;
1052- if ( stat . isDirectory ( ) ) throw new Error ( `Refusing to overwrite directory during snapshot apply: ${ target } ` ) ;
1053+ if ( stat . isDirectory ( ) && ! deletePaths . has ( target ) ) {
1054+ throw new Error ( `Refusing to overwrite directory during snapshot apply: ${ target } ` ) ;
1055+ }
10531056 } catch ( error ) {
10541057 if ( ( error as NodeJS . ErrnoException ) . code !== "ENOENT" ) throw error ;
10551058 }
You can’t perform that action at this time.
0 commit comments