-
Notifications
You must be signed in to change notification settings - Fork 2.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
Implement recursive
option in fs.readdir
#7296
Conversation
❌ @Jarred-Sumner 6 files with test failures on bun-darwin-aarch64:
|
✅ test failures on linux-x64 have been resolved. |
❌ @Jarred-Sumner 6 files with test failures on bun-darwin-x64:
|
❌ @Jarred-Sumner 7 files with test failures on bun-darwin-x64-baseline:
|
ref: bun.Async.KeepAlive = .{}, | ||
tracker: JSC.AsyncTaskTracker, | ||
|
||
// It's not 100% clear this one is necessary |
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.
hi @Jarred-Sumner , wanted to know your opinion on comments like these?
are they cool for all code bases or you add these cause you're the owner.
Thanks for your great work!
@@ -2052,3 +2052,7 @@ pub fn exitThread() noreturn { | |||
@panic("Unsupported platform"); | |||
} | |||
} | |||
|
|||
pub fn outOfMemory() noreturn { |
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.
thank you for using this pattern.
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.
no meaningful comments, this looks good
}; | ||
var list = bun.default_allocator.create(ResultListEntry) catch bun.outOfMemory(); | ||
errdefer { | ||
bun.default_allocator.destroy(list); |
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.
nitpick: is this code ever run?
Zig has
errdefer
, which evaluates the deferred expression on block exit path if and only if the function returned with an error from the block.
(there is no return error
case)
} | ||
|
||
if (comptime recursive) { | ||
@panic("This code path should never be reached. It should only go through readdirWithEntriesRecursiveAsync."); |
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.
can this be @compileError
?
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 tried. But no, unfortunately
* Implement `fs.readdir(path, {recursive: true})` and `fs.readdirSync(path, {recursive: true})` * Update node_fs.zig * FIx memory leak in error code * Add fail test * Update readdir.mjs * Update bun.zig * Update readdir.mjs --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Doesn't this forget to update the type definitions? My LSP is complaining when I pass |
* Implement `fs.readdir(path, {recursive: true})` and `fs.readdirSync(path, {recursive: true})` * Update node_fs.zig * FIx memory leak in error code * Add fail test * Update readdir.mjs * Update bun.zig * Update readdir.mjs --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
What does this PR do?
This implements support for
readdir(path, {recursive: true})
How did you verify your code works?
There are tests.