fs: add skipSymlinkDir option to skip symbolic dirs for fs.readdir#52553
Closed
kylo5aby wants to merge 1 commit intonodejs:mainfrom
Closed
fs: add skipSymlinkDir option to skip symbolic dirs for fs.readdir#52553kylo5aby wants to merge 1 commit intonodejs:mainfrom
kylo5aby wants to merge 1 commit intonodejs:mainfrom
Conversation
Member
|
/cc @nodejs/fs |
avivkeller
reviewed
Apr 16, 2024
| const skipSymlinkDir = options.skipSymlinkDir || false; | ||
|
|
||
| if (skipSymlinkDir) { | ||
| const stats = await lstat(originalPath); |
Member
There was a problem hiding this comment.
I'm no CPP expert, but benchmark-wise, wouldn't this call make us get the file twice? Is there a CPP way to achieve this same result?
Disclaimer: I'm not a CPP expert (or even a novice)
Contributor
Author
There was a problem hiding this comment.
I haven't find an effective way to acquire stat in cpp way directly to avoid this dilemma, it would be great if anyone could help, and this will only affect efficiency when using skipSymlinkDir to skip symbolic link dirs.
| pathModule.relative(originalPath, direntPath), | ||
| ); | ||
| if (skipSymlinkDir) { | ||
| const stats = await lstat(direntPath); |
Member
|
#49255 would implement a more general solution (provision of a filtering function to limit traversal). |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
skipSymlinkDiroption to thefs.readdirto allow for behavior similar to thefind [path] -printandfind -L [path] -printcommands. This option would control whether symbolic link directories are skipped or traversed during directory listing.fs.readdir([path], {withFileTypes: false})andfs.readdir([path], {withFileTypes: true})Refs: #51858