summaryrefslogtreecommitdiff
path: root/dotbot
diff options
context:
space:
mode:
authorAnish Athalye <me@anishathalye.com>2014-07-15 18:25:53 -0700
committerAnish Athalye <me@anishathalye.com>2014-07-15 18:25:53 -0700
commita97096ef962f64d98d70e92ec21f9edb4842985a (patch)
tree92844cbc00d829b3e4e436cf9f62d897ab278e63 /dotbot
parent4feb4845e8456ec3aa8e3764a29297bafc35d78c (diff)
Make Linker check for existence of targets
Linker now reports an error when links are configured to point to nonexistent targets. This fixes the old behavior where Linker silently created invalid links.
Diffstat (limited to 'dotbot')
-rw-r--r--dotbot/executor/linker.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/dotbot/executor/linker.py b/dotbot/executor/linker.py
index 662683f..0e25838 100644
--- a/dotbot/executor/linker.py
+++ b/dotbot/executor/linker.py
@@ -55,10 +55,11 @@ class Linker(Executor):
'''
success = False
source = os.path.join(self._base_directory, source)
- if not self._exists(link_name) and self._is_link(link_name):
+ if (not self._exists(link_name) and self._is_link(link_name) and
+ self._link_destination(link_name) != source):
self._log.warning('Invalid link %s -> %s' %
(link_name, self._link_destination(link_name)))
- elif not self._exists(link_name):
+ elif not self._exists(link_name) and self._exists(source):
self._log.lowinfo('Creating link %s -> %s' % (link_name, source))
os.symlink(source, os.path.expanduser(link_name))
success = True
@@ -66,9 +67,16 @@ class Linker(Executor):
self._log.warning(
'%s already exists but is a regular file or directory' %
link_name)
- elif self._link_destination(link_name) != source:
+ elif self._is_link(link_name) and self._link_destination(link_name) != source:
self._log.warning('Incorrect link %s -> %s' %
(link_name, self._link_destination(link_name)))
+ elif not self._exists(source):
+ if self._is_link(link_name):
+ self._log.warning('Nonexistant target %s -> %s' %
+ (link_name, source))
+ else:
+ self._log.warning('Nonexistant target for %s : %s' %
+ (link_name, source))
else:
self._log.lowinfo('Link exists %s -> %s' % (link_name, source))
success = True