`copy-tree`, when following links, does not copy contents of symbolicly linked sub-dir
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 35/100
Research direction
Start with the copy-tree entry point and run the Clojure reproduction from the issue, comparing the follow-links and nofollow-links behavior. Done means copying with default link following produces link-bar with the same nested contents as bar, while nofollow-links continues to preserve the symbolic link.
Written by the indexing model from the issue text.
Description
Issue
When asked to follow links, copy-tree copies symbolically linked subdirs, but not their content.
Repro
Setup scenario
(fs/create-dirs "src-dir/bar/baz")
(spit "src-dir/bar/baz/somefile.txt" "bippity boo")
(fs/create-sym-link "src-dir/link-bar" "bar")
We have:
└── src-dir/
├── bar/
│ └── baz/
│ └── somefile.txt
└── link-bar -> bar/
Perform copy-tree (which currently follows symbolic links by default):
(fs/copy-tree "src-dir" "dest-dir")
We now have:
├── dest-dir/
│ ├── bar/
│ │ └── baz/
│ │ └── somefile.txt
│ └── link-bar/
└── src-dir/
├── bar/
│ └── baz/
│ └── somefile.txt
└── link-bar -> bar/
Notice that link-bar/ is copied as a dir but there is nothing underneath it.
Expected Behaviour
Shouldn't dest-dir/link-bar/ have the same subdirs as dest-dir/bar?
Explore
What happens when we don't follow links?
(fs/copy-tree "src-dir" "dest-dir-nf" {:nofollow-links true})
Gives us:
dest-dir-nf/
├── bar/
│ └── baz/
│ └── somefile.txt
└── link-bar -> bar/
This seems correct.
What does cp do?
Let's compare with an equivalent cp that follows links:
$ cp -r --dereference src-dir dest-dir-cp
$ tree -F dest-dir-cp
dest-dir-cp/
├── bar/
│ └── baz/
│ └── somefile.txt
└── link-bar/
└── baz/
└── somefile.txt
Notice that link-bar/, unlike copy-tree, has the same contents as bar/.
And what about a cp that does not follow links:
$ cp -r src-dir dest-dir-cp-nf
$ tree -F dest-dir-cp-nf
dest-dir-cp-nf/
├── bar/
│ └── baz/
│ └── somefile.txt
└── link-bar -> bar/
This matches copy-tree when not following links.
Next steps
Discuss, decide, make changes.
Happy to do up PR when we see the path.
- Dominant language
- Clojure
- Stars
- 221
- Forks
- 52
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from babashka/fs
-
Difficulty 2/5 1-3 hours Newbie friendliness 48/100
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
-
Difficulty 5/5 Over a week Newbie friendliness 30/100
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
-
Difficulty 5/5 Over a week Newbie friendliness 30/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
nextjournal/clerk#830 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
IOP tokens release blocker team qa team qa autotests WG adoption
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
penpot/penpot#13540 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
izhangzhihao/intellij-rainbow-brackets#2903 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 67/100