-
Notifications
You must be signed in to change notification settings - Fork 29.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[v18.x backport] fs: fix the file name is not included when the withFileTypes option of readdir #53969
Conversation
3ef999e
to
7e1b5de
Compare
Congrats on your first contribution! 🎉 |
9d97bac
to
d740bdb
Compare
The git config was not set up properly, so I committed it again. 😅 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one is simply very hard to fix without introducing more breaking changes. It might be more wise to consider dirent.path
irremediably broken and switch to using dirent.parentPath
which is stable.
@@ -128,7 +128,7 @@ for (let i = 0; i < expected.length; i++) { | |||
} | |||
|
|||
function getDirentPath(dirent) { | |||
return pathModule.relative(testDir, dirent.path); | |||
return pathModule.relative(testDir, pathModule.join(dirent.path, dirent.name)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is not OK, we cannot make this kind of breaking change, especially on a maintenance LTS line. This needs to remain as it was on v18.19.1:
return pathModule.relative(testDir, dirent.path); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got it! I fixed in b2d61d8.
Many Thanks!
@aduh95 Thanks for the review!
Does the above mean modifying the // dir.js
readSyncRecursive(dirent) {
const ctx = { path: dirent.parentPath };
const handle = dirBinding.opendir(
pathModule.toNamespacedPath(dirent.parentPath),
this[kDirOptions].encoding,
undefined,
ctx,
);
handleErrorFromBinding(ctx);
const result = handle.read(
this[kDirOptions].encoding,
this[kDirOptions].bufferSize,
undefined,
ctx,
);
if (result) {
this.processReadResult(dirent.parentPath, result);
}
handle.close(undefined, ctx);
handleErrorFromBinding(ctx);
} Could you please help me a little more? |
The getDirentPath function in test/sequential/test-fs-opendir-recursive.js has been reverted for stability. Refs: nodejs#53969 (comment)
No I meant for user land, Im unsure fixing it in Node.js is worth it |
The issue was caused by a modification in PR nodejs#51021, which included changes to the documentation for parentPath and modifications to display the file path. I have retained the content related to the documentation and removed the filepath part. Fixes: nodejs#52441 Co-authored-by: injae-kim <injae-kim@users.noreply.github.com>
An error occurred in the test/sequential/test-fs-opendir-recursive.js file after changing the code. This was resolved by referring to the code resolved in PR nodejs#49603. Refs: nodejs#49603
The getDirentPath function in test/sequential/test-fs-opendir-recursive.js has been reverted for stability. Refs: nodejs#53969 (comment)
b2d61d8
to
4d34bb6
Compare
Doesn't make sense this statement since on the sync version we have the correct behavior, unless you want to change the sync version. |
No that would be equally unwise IMO. What I'm saying is that |
I will wait for the direction of the work to be decided. If you decide, please let me know! |
This fixes the issue reported in #52441
The issue was caused by a modification in PR #51021 , which was working on including the
parentPath
in the documentation and modifying thepath
to display thefilepath
.I have retained the content related to the documentation and removed the
filepath
part. Corresponding test code has also been updated accordingly.An error occurred in the
test/sequential/test-fs-opendir-recursive.js
file after changing the code. This was resolved by referring to the code resolved in #49603 .cc. @H4ad @daeyeon
Screenshots
AS-IS
You can see that even the file name is exposed in the
path
.TO-BE
Now the file name has been removed from the
path
!References
dirent.parentPath
#50976dirent.parentPath
#51021