merge_tree(symlinks=True) cannot overwrite an existing destination symlink
Nobody has claimed this yet.
- #264 by @00200200 — closed without merging
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 76/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- python
- Domain
- operating-systems
Research direction
Start at the Python implementation of Path.merge_tree and reproduce the supplied example with symlinks=True. Trace the symlink destination handling, then verify that a second merge succeeds and that changed targets, files, and directories at the destination are replaced as described.
Written by the indexing model from the issue text.
Description
When merge_tree is used to re-sync a directory tree that contains symbolic links (for example a deploy or backup copy run more than once), the second call fails:
FileExistsError: [Errno 17] File exists: .../file.txt -> .../link.txt
Regular files are overwritten via copy2, and the docstring says merge_tree copies "overwriting existing contents in dst". Symlinks take a different path that calls os.symlink without replacing dest, so a repeated merge cannot complete.
from path import Path
src, dst = Path('A'), Path('B')
src.mkdir(); dst.mkdir()
(src / 'file.txt').write_text('hello')
(src / 'file.txt').symlink(src / 'link.txt')
src.merge_tree(dst, True)
src.merge_tree(dst, True) # FileExistsError
Expected: the second merge succeeds and the destination symlink is replaced (including when the link target has changed, or when dest is a file/directory with the same name).
- Dominant language
- Python
- Stars
- 1.1k
- Forks
- 172
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
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 jaraco/path
-
`Path.cwd()` is missing a return type annotationPossibly taken @purplezimmermann claimed this 296 days ago. Open
Difficulty 1/5 Under an hour Newbie friendliness 55/100
-
`pygments` and `types-pywin32` should be moved to extrasPossibly taken @agammann claimed this 52 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 48/100
-
Tests fail when OpenSSL FIPS is enabledPossibly taken @grahamc claimed this 304 days ago. Open
Difficulty 3/5 1-2 days Newbie friendliness 45/100
-
help wanted
Difficulty 5/5 Over a week Newbie friendliness 35/100
Similar issues
-
area:cli area:security bug priority:medium
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
docs pydanty:is-working
Difficulty 1/5 Under an hour Newbie friendliness 88/100
pydantic/pydantic-ai#13563 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
NCATSTranslator/Babel#1204 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
alltheplaces/alltheplaces#20570 · 2 comments ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
sio2project/oioioi#981 · 1 reaction ·
Maintainers usually reply within 1 day