-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lib: avoid excluding symlinks in recursive fs.readdir with filetypes
Fixes: #52663 Signed-off-by: Juan José Arboleda <[email protected]> PR-URL: #55714 Reviewed-By: Ethan Arrowood <[email protected]> Reviewed-By: James M Snell <[email protected]>
- Loading branch information
Showing
2 changed files
with
40 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
'use strict'; | ||
|
||
// Refs: https://github.com/nodejs/node/issues/52663 | ||
const common = require('../common'); | ||
const assert = require('node:assert'); | ||
const fs = require('node:fs'); | ||
const path = require('node:path'); | ||
|
||
if (!common.canCreateSymLink()) | ||
common.skip('insufficient privileges'); | ||
|
||
const tmpdir = require('../common/tmpdir'); | ||
const readdirDir = tmpdir.path; | ||
// clean up the tmpdir | ||
tmpdir.refresh(); | ||
|
||
// a/1, a/2 | ||
const a = path.join(readdirDir, 'a'); | ||
fs.mkdirSync(a); | ||
fs.writeFileSync(path.join(a, '1'), 'irrelevant'); | ||
fs.writeFileSync(path.join(a, '2'), 'irrelevant'); | ||
|
||
// b/1 | ||
const b = path.join(readdirDir, 'b'); | ||
fs.mkdirSync(b); | ||
fs.writeFileSync(path.join(b, '1'), 'irrelevant'); | ||
|
||
// b/c -> a | ||
const c = path.join(readdirDir, 'b', 'c'); | ||
fs.symlinkSync(a, c, 'dir'); | ||
|
||
// Just check that the number of entries are the same | ||
assert.strictEqual( | ||
fs.readdirSync(b, { recursive: true, withFileTypes: true }).length, | ||
fs.readdirSync(b, { recursive: true, withFileTypes: false }).length | ||
); |