Skip to content

CI check: fs: respect force: false for symlinks in cp - #1

Closed
kuldeepsinh19 wants to merge 3 commits into
mainfrom
fs-cp-symlink-force
Closed

kuldeepsinh19 wants to merge 3 commits into
mainfrom
fs-cp-symlink-force

Conversation

@kuldeepsinh19

Copy link
Copy Markdown
Owner

CI-only PR inside my fork to run the full Node test workflows before opening the upstream PR for nodejs#66774. Not for merge.

When cp() or fsPromises.cp() copied a symlink with force set to false,
an existing destination symlink was still replaced, and an existing
file failed with EEXIST from symlink(2). errorOnExist was ignored in
both cases.

This is a breaking change: with force set to false, an existing
destination is now left in place, as it already is when copying a
file, or the copy fails with ERR_FS_CP_EEXIST when errorOnExist is
set. This is the behavior the documentation describes for both
options. Copies with force set to true, the default, are unchanged.

Refs: nodejs#66774
Signed-off-by: kuldeepsinh19 <kuldeepsinhrajput1919@gmail.com>
cpSync() had the same problem as cp() when it copied a symlink, on its
own or inside a directory copied with a filter function: with force
set to false, an existing destination symlink was replaced, an
existing file failed with EEXIST from symlink(2), and a dangling
destination symlink failed with ENOENT. errorOnExist was ignored.

This is a breaking change: with force set to false, an existing
destination is now left in place, or the copy fails with
ERR_FS_CP_EEXIST when errorOnExist is set, as with cp(). onLink() now
takes the options to check them. Copies with force set to true, the
default, are unchanged.

Refs: nodejs#66774
Signed-off-by: kuldeepsinh19 <kuldeepsinhrajput1919@gmail.com>
Without a filter function, a recursive cpSync() copies the directory
in C++. With force set to false, that walk still replaced an existing
destination symlink, as a comment there pointed out, and failed with
EEXIST for an existing file, for a dangling symlink, and for anything
already there when verbatimSymlinks was set.

This is a breaking change: with force set to false, an existing
destination is now left in place, as in the JavaScript walk. It is
looked up with symlink_status(), so that a dangling symlink counts as
existing, as it does for lstat() there. Copies with force set to true,
the default, are unchanged.

Fixes: nodejs#66774
Signed-off-by: kuldeepsinh19 <kuldeepsinhrajput1919@gmail.com>
@kuldeepsinh19

Copy link
Copy Markdown
Owner Author

Superseded by the rebased CI check in the next PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant