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

copySync fails when there is a symlink in the source directory and the operation has already been done once. #1043

Closed
a-lcardos opened this issue Jul 1, 2024 · 1 comment

Comments

@a-lcardos
Copy link

  • Operating System: macOs 14.4.1
  • Node.js version: v18.16.0
  • fs-extra version: [email protected]

Situation: when I have a directory "/tmp/a" that has a symlink and I try to copy this directory to "/tmp/b" which has the same symlink copySync fails.

✗ ls -lah /tmp/a
total 0
drwxr-xr-x   3 l  wheel    96B  1 Jul 09:22 .
drwxrwxrwt  17 root     wheel   544B  1 Jul 09:23 ..
lrwxr-xr-x   1 l  wheel    14B  1 Jul 09:19 symlink-to-real-file -> /tmp/real-file
✗ ls -lah /tmp/b
total 0
drwxr-xr-x   3 l  wheel    96B  1 Jul 09:25 .
drwxrwxrwt  17 root     wheel   544B  1 Jul 09:23 ..
lrwxr-xr-x   1 l  wheel    14B  1 Jul 09:20 symlink-to-real-file -> /tmp/real-file

The code:

copySync('/tmp/a', '/tmp/b');

Throws:

/Volumes/workplace/TestBug/node_modules/fs-extra/lib/copy/copy-sync.js:143
      throw new Error(`Cannot copy '${resolvedSrc}' to a subdirectory of itself, '${resolvedDest}'.`)
      ^

Error: Cannot copy '/tmp/real-file' to a subdirectory of itself, '/tmp/real-file'.

The same call succeeds if we have a file instead of a symlink.

@RyanZim
Copy link
Collaborator

RyanZim commented Jul 2, 2024

This is a known bug; previously reported in #1019.

@RyanZim RyanZim closed this as not planned Won't fix, can't repro, duplicate, stale Jul 2, 2024
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

No branches or pull requests

2 participants