aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Jon Bernard <jbernard@tuxion.com> 2013-12-17 21:57:32 -0500
committerGravatar Jon Bernard <jbernard@tuxion.com> 2013-12-17 21:57:32 -0500
commit590b17bb6de0468bb477b194c87c5fb9ba73e25d (patch)
tree1653361c3c3bb1555814ce73f36efdda95e9179b
parent6a25fdf8cca4236a2fc2314902b9f072714632e2 (diff)
downloaddotfiles-590b17bb6de0468bb477b194c87c5fb9ba73e25d.tar.gz
dotfiles-590b17bb6de0468bb477b194c87c5fb9ba73e25d.tar.bz2
dotfiles-590b17bb6de0468bb477b194c87c5fb9ba73e25d.zip
Only replace existing dotfiles on remove operation
It is possible that the dotifle is removed from the repository before the remove is issued. In this case only the symlink is removed. Fixes #25
-rw-r--r--dotfiles/core.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/dotfiles/core.py b/dotfiles/core.py
index 14ef8e0..3212939 100644
--- a/dotfiles/core.py
+++ b/dotfiles/core.py
@@ -92,11 +92,17 @@ class Dotfile(object):
self._symlink(self.target, self.name)
def remove(self):
+
if self.status != '':
print("Skipping \"%s\", file is %s" % (self.basename, self.status))
return
+
+ # remove the existing symlink
self._remove(self.name)
- self._move(self.target, self.name)
+
+ # return dotfile to its original location
+ if os.path.exists(self.target):
+ self._move(self.target, self.name)
def __str__(self):
user_home = os.environ['HOME']