From 58490d5098475e709730e78ea5a3369c6e9876ad 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. PR-URL: https://github.com/nodejs/node/pull/22808 Reviewed-By: James M Snell Reviewed-By: Anna Henningsen Reviewed-By: Bryan English Reviewed-By: Colin Ihrig Reviewed-By: Michael Dawson --- 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 889cafa3842c8c..5a5ac3bfa263b0 100644 --- a/lib/internal/fs/utils.js +++ b/lib/internal/fs/utils.js @@ -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]);