Skip to content

Commit

Permalink
fs: consistently return symlink type from readdir
Browse files Browse the repository at this point in the history
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: #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>
  • Loading branch information
ajafff authored and targos committed Oct 3, 2018
1 parent 074b7af commit bb6530b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/internal/fs/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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]);
Expand Down

0 comments on commit bb6530b

Please sign in to comment.