fs: consistently return symlink type from readdir
Use 'lstat' to determine type of directory entry. This is more consistent with the type returned from the readdir binding. Also use 'path.join' over 'path.resolve' because 'name' is not absolute. PR-URL: https://github.com/nodejs/node/pull/22808 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Bryan English <bryan@bryanenglish.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
This commit is contained in:
parent
7dae8729aa
commit
83864b3bb0
@ -131,7 +131,7 @@ function getDirents(path, [names, types], callback) {
|
||||
const name = names[i];
|
||||
const idx = i;
|
||||
toFinish++;
|
||||
lazyLoadFs().stat(pathModule.resolve(path, name), (err, stats) => {
|
||||
lazyLoadFs().lstat(pathModule.join(path, name), (err, stats) => {
|
||||
if (err) {
|
||||
callback(err);
|
||||
return;
|
||||
@ -154,7 +154,7 @@ function getDirents(path, [names, types], callback) {
|
||||
const type = types[i];
|
||||
if (type === UV_DIRENT_UNKNOWN) {
|
||||
const name = names[i];
|
||||
const stats = lazyLoadFs().statSync(pathModule.resolve(path, name));
|
||||
const stats = lazyLoadFs().lstatSync(pathModule.join(path, name));
|
||||
names[i] = new DirentFromStats(name, stats);
|
||||
} else {
|
||||
names[i] = new Dirent(names[i], types[i]);
|
||||
|
Loading…
x
Reference in New Issue
Block a user