Repository navigation
[fs.cp] fails with EPERM despite filter #44720
Copy link
Copy link
Labels
fsIssues and PRs related to file-system APIs and the fs module.Issues and PRs related to file-system APIs and the fs module.good first issueIssues that are suitable for first-time contributors.Issues that are suitable for first-time contributors.
Description
Activity
- addedfsIssues and PRs related to file-system APIs and the fs module.Issues and PRs related to file-system APIs and the fs module.
on Sep 19, 2022 I assume it is because
copyDircallscheckPathsSync(), which invokeslstat(), before it callsstartCopy(), which applies the filter. Given that the filter function only receives the paths and not the result oflstat(), it should be relatively simple to change that.- addedgood first issueIssues that are suitable for first-time contributors.Issues that are suitable for first-time contributors.
on Sep 24, 2022 @tniessen am I right if we should add this check before calling checkPathsSync()?
if (opts.filter && !opts.filter(srcItem, destItem)) continue;And since the startCopy has 2 lines and one of them is the filter call, should we move its main logic to copyDir and remove this function? Overall, the copyDir will look like this:
function copyDir(src, dest, opts) { const dir = opendirSync(src); try { let dirent; while ((dirent = dir.readSync()) !== null) { const { name } = dirent; const srcItem = join(src, name); const destItem = join(dest, name); if (opts.filter && !opts.filter(srcItem, destItem)) continue; const { destStat } = checkPathsSync(srcItem, destItem, opts); getStats(destStat, srcItem, destItem, opts); } } finally { dir.closeSync(); } }- added 2 commits that reference this issue
on Sep 25, 2022 - added a commit that references this issue
on Oct 10, 2022 - added a commit that references this issue
on Oct 11, 2022 - added a commit that references this issue
on Nov 1, 2022 - added a commit that references this issue
on Nov 1, 2022 - added a commit that references this issue
on Nov 10, 2022
Metadata
Metadata
Assignees
Labels
fsIssues and PRs related to file-system APIs and the fs module.Issues and PRs related to file-system APIs and the fs module.good first issueIssues that are suitable for first-time contributors.Issues that are suitable for first-time contributors.
Version
v18.9.0
Platform
Microsoft Windows NT 10.0.19044.0 x64
Subsystem
No response
What steps will reproduce the bug?
How often does it reproduce? Is there a required condition?
Happens every time. Both drives are external, connected via USB.
Source can also be a subdirectory, analogous error.
I generally use Powershell Core, not the built-in Powershell.
But the same happens there.
What is the expected behavior?
The copy operation proceeds without trying to access the filtered-out directory.
What do you see instead?
Additional information
This was triggered by jprichardson/node-fs-extra#965 (comment)