diff options
author | Anish Athalye <me@anishathalye.com> | 2014-11-09 09:00:19 -0500 |
---|---|---|
committer | Anish Athalye <me@anishathalye.com> | 2014-11-09 09:08:13 -0500 |
commit | bc43348f42fa4beba2d60a1dfe9c3c6cfde78efa (patch) | |
tree | 60de726183f457c0a28de8541f1478dc445ac9d6 /dotbot | |
parent | 33d602bb9304b2daf54a5754f5fb51cfcad350dc (diff) |
Fix bug with forced links not working in all cases
This commit fixes a bug where forced links did not work on certain types
of bad links. Until this fix, forced links only worked if the original
was a real file or directory. This commit fixes this, so that the forced
link option also works when the original is a broken or incorrect
symbolic link.
Diffstat (limited to 'dotbot')
-rw-r--r-- | dotbot/executor/linker.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/dotbot/executor/linker.py b/dotbot/executor/linker.py index c3d6dc5..8f38c95 100644 --- a/dotbot/executor/linker.py +++ b/dotbot/executor/linker.py @@ -27,7 +27,7 @@ class Linker(Executor): if create: success &= self._create(destination) if force: - success &= self._delete(destination) + success &= self._delete(path, destination) else: path = source success &= self._link(path, destination) @@ -71,9 +71,11 @@ class Linker(Executor): self._log.lowinfo('Creating directory %s' % parent) return success - def _delete(self, path): + def _delete(self, source, path): success = True - if self._exists(path) and not self._is_link(path): + source = os.path.join(self._base_directory, source) + if ((self._is_link(path) and self._link_destination(path) != source) or + (self._exists(path) and not self._is_link(path))): fullpath = os.path.expanduser(path) try: if os.path.isdir(fullpath): |