From 590b17bb6de0468bb477b194c87c5fb9ba73e25d Mon Sep 17 00:00:00 2001 From: Jon Bernard Date: Tue, 17 Dec 2013 21:57:32 -0500 Subject: 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 --- dotfiles/core.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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'] -- cgit v1.2.3