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

cpSync symlink handling regression #54730

Closed
PhilipTrauner opened this issue Sep 3, 2024 · 3 comments · Fixed by #54732
Closed

cpSync symlink handling regression #54730

PhilipTrauner opened this issue Sep 3, 2024 · 3 comments · Fixed by #54732
Labels
fs Issues and PRs related to the fs subsystem / file system. regression Issues related to regressions. repro-exists Issues with reproductions. v22.x v22.x Issues that can be reproduced on v22.x or PRs targeting the v22.x-staging branch.

Comments

@PhilipTrauner
Copy link

Version

v22.6.0

Platform

Darwin Quantum 23.6.0 Darwin Kernel Version 23.6.0: Fri Jul  5 17:56:41 PDT 2024; root:xnu-10063.141.1~2/RELEASE_ARM64_T6000 arm6

Subsystem

fs

What steps will reproduce the bug?

override a directory with a symlink to a directory with {dereference: true}

How often does it reproduce? Is there a required condition?

consistently

What is the expected behavior? Why is that the expected behavior?

the source symlink should be derefenced

What do you see instead?

the source symlink is not derefenced

bool src_is_dir = src_status.type() == std::filesystem::file_type::directory;

Additional information

No response

@RedYetiDev RedYetiDev added the fs Issues and PRs related to the fs subsystem / file system. label Sep 3, 2024
@RedYetiDev
Copy link
Member

Can you provide an example that shows this bug? That'll make it easier to reproduce

@jazelly
Copy link
Member

jazelly commented Sep 3, 2024

I found a reproduce step.

  1. create a original dir a, with some files inside
  2. create a symlink b by ln -s ./a ./b
  3. create a dir c to be overrided
  4. execute the following script
import fs from 'fs';
fs.cpSync('./b', './c', { recursive: true, dereference: true})
  1. observe ERR_FS_CP_NON_DIR_TO_DIR

This is not happening in 22.5.1

@RedYetiDev RedYetiDev added repro-exists Issues with reproductions. v22.x v22.x Issues that can be reproduced on v22.x or PRs targeting the v22.x-staging branch. and removed repro-exists Issues with reproductions. labels Sep 3, 2024
@RedYetiDev
Copy link
Member

RedYetiDev commented Sep 3, 2024

$ mkdir a
$ touch a/some_file
$ ln -s ./a ./b
$ mkdir c
$ node -e "fs.cpSync('./b', './c', { recursive: true, dereference: true})"
node:internal/fs/cp/cp-sync:56
  fsBinding.cpSyncCheckPaths(src, dest, opts.dereference, opts.recursive);
            ^

Error: Cannot overwrite directory ./c with non-directory ./b
    at cpSyncFn (node:internal/fs/cp/cp-sync:56:13)
    at Object.cpSync (node:fs:3046:3)
    at [eval]:1:4
    at runScriptInThisContext (node:internal/vm:209:10)
    at node:internal/process/execution:118:14
    at [eval]-wrapper:6:24
    at runScript (node:internal/process/execution:101:62)
    at evalScript (node:internal/process/execution:136:3)
    at node:internal/main/eval_string:55:3 {
  code: 'ERR_FS_CP_NON_DIR_TO_DIR'
}

Node.js v22.7.0

nodejs-github-bot pushed a commit that referenced this issue Sep 5, 2024
Co-authored-by: Jake Yuesong Li <jake.yuesong@gmail.com>
PR-URL: #54732
Fixes: #54730
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
aduh95 pushed a commit that referenced this issue Sep 12, 2024
Co-authored-by: Jake Yuesong Li <jake.yuesong@gmail.com>
PR-URL: #54732
Fixes: #54730
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
louwers pushed a commit to louwers/node that referenced this issue Nov 2, 2024
Co-authored-by: Jake Yuesong Li <jake.yuesong@gmail.com>
PR-URL: nodejs#54732
Fixes: nodejs#54730
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fs Issues and PRs related to the fs subsystem / file system. regression Issues related to regressions. repro-exists Issues with reproductions. v22.x v22.x Issues that can be reproduced on v22.x or PRs targeting the v22.x-staging branch.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants