File tree 1 file changed +8
-2
lines changed
1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -200,7 +200,10 @@ FS.staticInit();
200
200
try {
201
201
current = FS . lookupNode ( current , parts [ i ] ) ;
202
202
} catch ( e ) {
203
- if ( ( e ?. errno === { { { cDefs . ENOENT } } } ) && islast && opts . handleBrokenLink ) {
203
+ // if noent_okay is true, suppress a ENOENT in the last component
204
+ // and return an object with an undefined node. This is needed for
205
+ // resolving symlinks in the path when creating a file.
206
+ if ( ( e ?. errno === { { { cDefs . ENOENT } } } ) && islast && opts . noent_okay ) {
204
207
return { path : current_path } ;
205
208
}
206
209
throw e ;
@@ -1022,9 +1025,12 @@ FS.staticInit();
1022
1025
node = path ;
1023
1026
} else {
1024
1027
path = PATH . normalize ( path ) ;
1028
+ // noent_okay makes it so that if the final component of the path
1029
+ // doesn't exist, lookupPath returns `node: undefined`. `path` will be
1030
+ // updated to point to the target of all symlinks.
1025
1031
var lookup = FS . lookupPath ( path , {
1026
1032
follow : ! ( flags & { { { cDefs . O_NOFOLLOW } } } ) ,
1027
- handleBrokenLink : true
1033
+ noent_okay : true
1028
1034
} ) ;
1029
1035
node = lookup . node ;
1030
1036
path = lookup . path ;
You can’t perform that action at this time.
0 commit comments