Repository navigation
fs: skip cp fast path when a vfs is mounted - #67893
Open
hamzakargin wants to merge 1 commit into
Open
hamzakargin wants to merge 1 commit into
hamzakargin wants to merge 1 commit into
Conversation
The native directory copy added in 29667e0 cannot see paths inside a node:vfs mount, so fs.cp() and fs.promises.cp() of a directory failed there with ENOTDIR. Use the JavaScript walk while a virtual file system is mounted. Fixes: nodejs#67892 Refs: nodejs#65488 Assisted-by: AI coding agents Signed-off-by: Hamza KargΔ±n <hamzakargin@outlook.com>
Codecov Reportβ
All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #67893 +/- ##
==========================================
+ Coverage 90.58% 90.59% +0.01%
==========================================
Files 802 802
Lines 286656 286662 +6
Branches 55369 55381 +12
==========================================
+ Hits 259668 259708 +40
+ Misses 17089 17064 -25
+ Partials 9899 9890 -9
π New features to boost your workflow:
|
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.
The fast path from #65488 sends a directory copy to native code, which cannot see paths inside a VFS mount, so
fs.cp()andfs.promises.cp()of a directory fail there withENOTDIR. This PR skips the fast path while a VFS is mounted (vfsState.handlers !== null). Real disk users keep the fast path, and VFS users use the JS walk.Fixes: #67892
Testing: the new
test/parallel/test-vfs-fs-cp.jscopies a directory on VFS withfs.promises.cp()andfs.cp(), and checks that a real directory still copies while a VFS is mounted. It fails without the fix and passes with it. Alltest-fs-cp*andtest-vfs*tests pass locally (222 tests, macOS arm64), and ESLint is clean.AI disclosure: I used AI coding agents to help investigate the bug and write the fix and the test. I reviewed the change, reproduced the bug on main, and checked the test results above.