Skip to content

Commit

Permalink
lib: avoid excluding symlinks in recursive fs.readdir with filetypes
Browse files Browse the repository at this point in the history
Fixes: #52663
Signed-off-by: Juan José Arboleda <[email protected]>
  • Loading branch information
juanarbol committed Nov 4, 2024
1 parent 32ff100 commit 33f31fe
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -1401,9 +1401,12 @@ function readdirSyncRecursive(basePath, options) {
// of the first array within the result.
const length = readdirResult[0].length;
for (let i = 0; i < length; i++) {
// Avoid excluding symlinks, as they are not directories.
// Refs: https://github.com/nodejs/node/issues/52663
const stat = binding.internalModuleStat(binding, pathModule.join(path, readdirResult[0][i]));
const dirent = getDirent(path, readdirResult[0][i], readdirResult[1][i]);
ArrayPrototypePush(readdirResults, dirent);
if (dirent.isDirectory()) {
if (dirent.isDirectory() || stat === 1) {
ArrayPrototypePush(pathsQueue, pathModule.join(dirent.parentPath, dirent.name));
}
}
Expand Down

0 comments on commit 33f31fe

Please sign in to comment.