From 6197ca269bf4436d01f0084df7fd1485d666c83a Mon Sep 17 00:00:00 2001 From: Klaus Meinhardt Date: Tue, 11 Sep 2018 14:50:50 +0200 Subject: [PATCH] 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. --- lib/internal/fs/utils.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/internal/fs/utils.js b/lib/internal/fs/utils.js index acc566e37bb4bf..189b16b58b7d69 100644 --- a/lib/internal/fs/utils.js +++ b/lib/internal/fs/utils.js @@ -129,7 +129,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; @@ -152,7 +152,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]);