Skip to content

Commit

Permalink
Merge pull request #7 from shippy/master
Browse files Browse the repository at this point in the history
Fix the treatment of broken symlink
  • Loading branch information
vibhavp committed Nov 17, 2016
2 parents aeb31dc + ed0af66 commit 8fc1eab
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions dotty.py
Expand Up @@ -43,12 +43,13 @@ def create_directory(path):
def create_symlink(src, dest, replace):
dest = os.path.expanduser(dest)
src = os.path.abspath(src)
if os.path.exists(dest):
broken_symlink = os.path.lexists(dest) and not os.path.exists(dest)
if os.path.lexists(dest):
if os.path.islink(dest) and os.readlink(dest) == src:
print("Skipping existing {0} -> {1}".format(dest, src))
return
elif replace or ask_user(dest+" exists, delete it? [Y/n]"):
if os.path.isfile(dest):
if os.path.isfile(dest) or broken_symlink:
os.remove(dest)
else:
shutil.rmtree(dest)
Expand Down

0 comments on commit 8fc1eab

Please sign in to comment.