-
Notifications
You must be signed in to change notification settings - Fork 30.6k
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
fs.cpSync fails when copying to a directory with a name starting with the source directory name #54285
Comments
Thanks for the report! Seeing as you seem to know the cause, if you'd like, you can submit a patch PR. |
I've opened a PR patching this in #54288. Thanks again :-) |
present in node v22.7.0 `PS C:\temp\drtest> node run.js Error: Cannot copy \?\C:\temp\drtest\foo to a subdirectory of self \?\C:\temp\drtest\foobar Node.js v22.7.0 |
PR-URL: #55033 Fixes: #54285 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Joyee Cheung <[email protected]>
PR-URL: #55033 Fixes: #54285 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Joyee Cheung <[email protected]>
PR-URL: #55033 Fixes: #54285 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Joyee Cheung <[email protected]>
PR-URL: nodejs#55033 Fixes: nodejs#54285 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Joyee Cheung <[email protected]>
PR-URL: nodejs#55033 Fixes: nodejs#54285 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Joyee Cheung <[email protected]>
Version
v22.6.0
Platform
Subsystem
fs module
What steps will reproduce the bug?
How often does it reproduce? Is there a required condition?
This bug reproduces consistently in Node.js v22.6.0. It works correctly in v22.5.1.
What is the expected behavior? Why is that the expected behavior?
The expected behavior, as seen in v22.5.1, is that the
./foo
directory should be copied to./foobar
. This is the normal operation of thefs.cpSync
function and aligns with the documented behavior.What do you see instead?
In v22.6.0, the following error is thrown:
Additional information
The issue is caused by the misuse of the
starts_with
function in a newly added check. This check incorrectly prevents copying to directories whose names start with the source directory name. For details, see:https://github.com/nodejs/node/pull/53614/files#diff-70e3325bd2115867617ae2a16321c5de53c070ff2841976fe5b849675a5111e6R3186-R3190
The text was updated successfully, but these errors were encountered: