Skip to content

fix uninstall deleting dotpath files through a symlinked directory - #497

Merged
deadc0de6 merged 1 commit into
deadc0de6:masterfrom
jayhemnani9910:fix/uninstall-symlinked-dir
Nov 17, 2026
Merged

deadc0de6 merged 1 commit into
deadc0de6:masterfrom
jayhemnani9910:fix/uninstall-symlinked-dir

Conversation

@jayhemnani9910

Copy link
Copy Markdown
Contributor

dotdrop uninstall deletes the dotfiles in the dotpath when a directory dotfile was installed as a link.

dotdrop import -c config.yaml -p home -f -l absolute ~/.config/app
dotdrop install   -c config.yaml -p home -f   # ~/.config/app -> <repo>/dotfiles/config/app
dotdrop uninstall -c config.yaml -p home -f
find dotfiles -type f                          # before: nothing left; after: dotfiles/config/app/conf.ini

Without -f the prompt asks Remove ~/.config/app/conf.ini?, which reads like the installed copy, but it is the file in the repo. Same with link: relative and with link_children, where each child is a link.

Uninstaller._remove and _descend use os.path.isdir(), which is true for a symlink to a directory, so they descend into the link target (the dotpath) and remove every file there before removing the link. A symlink is now removed as a link.

tests-ng/uninstall.sh checked that the dotpath directory still exists, but not its files; it now also checks dotfiles/y/file and dotfiles/y/subdir/subfile, which fails without the change (absolute, relative and link_children). Unit tests pass; tests-ng: same results as on master here (import-with-trans.sh needs tree, update.sh also fails on master in this environment). Ran the steps above: the repo file is kept and only the link is removed.

A directory dotfile installed with link absolute/relative (or link_children) is a symlink to the dotpath. uninstall treated it as a directory and removed every file under it, which are the files in the dotpath, then the link. Remove the link itself instead.
@deadc0de6

Copy link
Copy Markdown
Owner

thanks!

@deadc0de6
deadc0de6 merged commit e27d0d8 into deadc0de6:master Nov 17, 2026
10 checks passed
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.

2 participants