Closed
Conversation
fix: nodejs#44720 issue: - `copyDir()` calls `checkPathsSync()`, which invokes `lstat()` which causes error because of not checking the opts.filter changes: - check opts.filter before calling `checkPathsSync` and copy logic - cleanup `startCopy` function
Collaborator
This was referenced Sep 27, 2022
16 tasks
Contributor
Author
test was added |
thoqbk
commented
Oct 1, 2022
| filter: path => !path.includes('foo'), | ||
| recursive: true, | ||
| }); | ||
| } |
Contributor
Author
There was a problem hiding this comment.
Before fixing, when I run this test it throws the following error because checkPathsSync(srcItem, destItem, opts) gets called even though the srcItem shouldn't be copied:
SystemError [ERR_FS_CP_DIR_TO_NON_DIR]: Cannot overwrite directory with non-directory: cp returned EISDIR (cannot overwrite directory /Users/xxx/dev/node/test/.tmp.0/copy_28/foo with non-directory /Users/xxx/dev/node/test/.tmp.0/copy_29/foo) /Users/xxx/dev/node/test/.tmp.0/copy_29/foo
at new SystemError (node:internal/errors:244:5)
at new NodeError (node:internal/errors:355:7)
at checkPathsSync (node:internal/fs/cp/cp-sync:77:13)
at copyDir (node:internal/fs/cp/cp-sync:287:28)
at onDir (node:internal/fs/cp/cp-sync:268:10)
at getStats (node:internal/fs/cp/cp-sync:171:12)
at handleFilterAndCopy (node:internal/fs/cp/cp-sync:158:10)
at cpSyncFn (node:internal/fs/cp/cp-sync:60:10)
at cpSync (node:fs:2899:3)
at file:///Users/xxx/dev/node/test/parallel/test-fs-cp.mjs:353:3 {
code: 'ERR_FS_CP_DIR_TO_NON_DIR',
info: {
message: 'cannot overwrite directory /Users/xxx/dev/node/test/.tmp.0/copy_28/foo with non-directory /Users/xxx/dev/node/test/.tmp.0/copy_29/foo',
path: '/Users/xxx/dev/node/test/.tmp.0/copy_29/foo',
syscall: 'cp',
errno: 21,
code: 'EISDIR'
},
errno: [Getter/Setter],
syscall: [Getter/Setter],
path: [Getter/Setter]
}
4c84e46 to
aa3e4f1
Compare
jasnell
reviewed
Oct 2, 2022
test/parallel/test-fs-cp.mjs
Outdated
| // It should not throw exception if child folder | ||
| // does not pass filter function | ||
| { | ||
| // Mimic there's a file in dest with the same name as the child folder in src |
Member
There was a problem hiding this comment.
The start of this sentence is a bit awkward.
aa3e4f1 to
ec30bf0
Compare
joyeecheung
reviewed
Oct 5, 2022
Member
joyeecheung
left a comment
There was a problem hiding this comment.
LGTM with a nit to clarify the comments.
joyeecheung
approved these changes
Oct 5, 2022
Co-authored-by: Joyee Cheung <joyeec9h3@gmail.com>
Contributor
Author
|
Rework PR #45143 |
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.
fix: #44720
issue:
copyDir()callscheckPathsSync(), which invokeslstat()causes error because of not checking the opts.filter
changes:
checkPathsSyncand copy logicstartCopyfunction