-
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
Async file copying on windows #8649
Conversation
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.
legendary
i have some really minor change requests
src/bun.js/node/node_fs.zig
Outdated
else | ||
0; | ||
if (windows.CreateSymbolicLinkW(dest, wbuf[0..len :0], flags) == 0) { | ||
if (Maybe(Return.CopyFile).errnoSysP(0, .copyfile, this.osPathIntoSyncErrorBuf(dest))) |e| { |
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 think you can pass the rc of the api call into this function, instead of 0. it will return null on success. this will eliminate the "should be unreachable" thing.
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.
passing rc
or 0
doesn't make a difference because rc
is known to be zero. The main issue is that constructing the error object may fail, for example if we detect that the status code is actually a success.
I've gone ahead and changed these to instead construct errors with a generic ENOENT
code, so that if these do ever get hit the error is at least somewhat helpful.
@@ -623,6 +623,15 @@ pub fn normalizeStringGeneric( | |||
) []u8 { | |||
return normalizeStringGenericT(u8, path_, buf, allow_above_root, separator, isSeparator, preserve_trailing_slash); | |||
} | |||
|
|||
fn separatorAdapter(comptime T: type, func: anytype) fn (T) bool { |
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 is fine but later this would be legendary to make into a generic wrapper for
"wrap any function with type"
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.
yeah I agree, could probably live in the bun namespace. Only problem is that zig doesn't support variadics, so it can't be fully generalized 🥲
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.
see std.meta.ArgsTuple
it’s like variadics but worse
src/resolver/resolve_path.zig
Outdated
return struct { | ||
allow_above_root: bool = false, | ||
separator: T = std.fs.path.sep, | ||
isSeparator: fn (T) bool = makeIsSepAnyT(T), |
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 wish this could be a comptime field but i suspect it isnt so shrimple to do so is it?
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.
which field do you think should be comptime?
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.
isSeparator. if i remember correctly it was previously a comptime function. i might be misremembering. what is significant is that i am less certain this function will be inlined. in the previous code (if im right and it used comptime function), then it is almost certain that LLVM inlined a function for this ==
thing
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.
because the entire struct is only ever used in a comptime context I think this should be basically equivalent to passing a comptime parameter (correct me if I'm wrong on that one)
❌ @gvilums 4 files with test failures on bun-darwin-aarch64:
|
❌ @gvilums 3 files with test failures on linux-x64: |
❌ @gvilums 3 files with test failures on linux-x64-baseline: |
❌ @gvilums 4 files with test failures on bun-darwin-x64:
|
❌🪟 @gvilums, there are 11 test regressions on Windows x86_64
|
awesome |
What does this PR do?
This PR implements
fs.promises.cp
on windows, and fixes some errors with symlinks withfs.cpSync
.How did you verify your code works?
Tests in
cp.test.ts