You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
How often does it reproduce? Is there a required condition?
Always
What is the expected behavior? Why is that the expected behavior?
No response
What do you see instead?
when withFileTypes: true, the directory entry dir1_s/1.txt haven't been outputted. However, I did not find any description in the documentation regarding the difference in handling symbolic directories between the two.
Additional information
I found that the reason is because the two use different conditions to determine whether to continue traversal. When {withFileTypes:true}. it use
Contrary to {withFileTypes:true}, "directory" and "symbolic link" are compatible, and then allows traversal to continue into 1.txt after encountering the symbolic directory dir1_s.
I'm not sure if this is work as expected. If it's not, I believe maintaining consistency with the results of {withFileTypes: false} would be preferable, aligning with the result of find -L [path].
The text was updated successfully, but these errors were encountered:
Version
21.6.0
Platform
Linux 5.15.0-41-generic #44-Ubuntu x86_64 GNU/Linux
Subsystem
fs
What steps will reproduce the bug?
For the directory tree below
dir ├── dir1 │ └── 1.txt └── dir1_s -> dir1
When using
fs.readdir
orfs.readdirSync
to read the contents ofdir
, there is a difference in the number of contents outputted by the two:So do
fs.readdir
.How often does it reproduce? Is there a required condition?
Always
What is the expected behavior? Why is that the expected behavior?
No response
What do you see instead?
when
withFileTypes: true
, the directory entrydir1_s/1.txt
haven't been outputted. However, I did not find any description in the documentation regarding the difference in handling symbolic directories between the two.Additional information
I found that the reason is because the two use different conditions to determine whether to continue traversal. When
{withFileTypes:true}
. it usenode/lib/fs.js
Line 1420 in 91dc8c9
As described by class
Dirent
,type
"directory" and "symbolic link" ofdirent
are mutually exclusive.When
{withFileTypes:false}
, is usenode/lib/fs.js
Line 1428 in 91dc8c9
Contrary to
{withFileTypes:true}
, "directory" and "symbolic link" are compatible, and then allows traversal to continue into1.txt
after encountering the symbolic directorydir1_s
.I'm not sure if this is work as expected. If it's not, I believe maintaining consistency with the results of
{withFileTypes: false}
would be preferable, aligning with the result offind -L [path]
.The text was updated successfully, but these errors were encountered: