Skip to content
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: fix opts.filter issue in cpSync #45143

Merged
merged 1 commit into from
Nov 1, 2022

Conversation

thoqbk
Copy link
Contributor

@thoqbk thoqbk commented Oct 24, 2022

Fixes: #44720

replicate #44922 for cpSync

issues:

  • copy sync API doesn't handle opts.filter properly.
    As a result, the path validation logic still gets triggered
    even though the file or folder is filtered out
  • no central place to handle opts.filter
    e.g. need to call opts.filter(src, dest) in several places

changes:

  • use checkPathsSync as a central place to validate the paths
    (with consideration of opts.filter) before copying
  • cleanup: remove startCopy, change function name handleFilterAndCopy
    to checkParentDir to make it consistent with copy async
  • update tests to test for both copy sync and async

@nodejs-github-bot nodejs-github-bot added fs Issues and PRs related to the fs subsystem / file system. needs-ci PRs that need a full CI run. labels Oct 24, 2022
test/parallel/test-fs-cp.mjs Outdated Show resolved Hide resolved
test/parallel/test-fs-cp.mjs Outdated Show resolved Hide resolved
@@ -145,24 +153,12 @@ function checkParentPathsSync(src, srcStat, dest) {
return checkParentPathsSync(src, srcStat, destParent);
}

function handleFilterAndCopy(destStat, src, dest, opts) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change the name to make it consistent with cp-async

@thoqbk thoqbk force-pushed the cp-sync-fix-opts-filter branch from 9033729 to bf2dde5 Compare October 25, 2022 01:51
@thoqbk thoqbk requested a review from aduh95 October 25, 2022 10:56
Copy link
Contributor

@aduh95 aduh95 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes LGTM, if you want to open a separate PR to investigate why the options object gets mutated that'd be great!

@theanarkh theanarkh added the request-ci Add this label to start a Jenkins CI on a PR. label Oct 31, 2022
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Oct 31, 2022
@nodejs-github-bot
Copy link
Collaborator

@aduh95 aduh95 added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Oct 31, 2022
@nodejs-github-bot
Copy link
Collaborator

@aduh95 aduh95 added the commit-queue Add this label to land a pull request using GitHub Actions. label Nov 1, 2022
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Nov 1, 2022
@nodejs-github-bot nodejs-github-bot merged commit a14fc49 into nodejs:main Nov 1, 2022
@nodejs-github-bot
Copy link
Collaborator

Landed in a14fc49

RafaelGSS pushed a commit that referenced this pull request Nov 1, 2022
PR-URL: #45143
Fixes: #44720
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
@RafaelGSS RafaelGSS mentioned this pull request Nov 1, 2022
lucshi pushed a commit to lucshi/node that referenced this pull request Nov 9, 2022
PR-URL: nodejs#45143
Fixes: nodejs#44720
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
RafaelGSS pushed a commit that referenced this pull request Nov 10, 2022
PR-URL: #45143
Fixes: #44720
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
danielleadams pushed a commit that referenced this pull request Dec 30, 2022
PR-URL: #45143
Fixes: #44720
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
danielleadams pushed a commit that referenced this pull request Dec 30, 2022
PR-URL: #45143
Fixes: #44720
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
danielleadams pushed a commit that referenced this pull request Jan 3, 2023
PR-URL: #45143
Fixes: #44720
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. fs Issues and PRs related to the fs subsystem / file system. needs-ci PRs that need a full CI run.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[fs.cp] fails with EPERM despite filter
4 participants