From 1a10f88c432113317387f9ad93c88c039b3907b8 Mon Sep 17 00:00:00 2001 From: Andreas Ntaflos Date: Mon, 27 Apr 2015 18:30:23 +0200 Subject: [PATCH] Handle force creation of symlinked directories Check if entry to force-create (delete) is a symlink and if so, simply unlink it. Don't try to run rmtree on the underlying directory, which will fail anyway. --- dotbot/executor/linker.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dotbot/executor/linker.py b/dotbot/executor/linker.py index d94a9bc..9821fe7 100644 --- a/dotbot/executor/linker.py +++ b/dotbot/executor/linker.py @@ -78,7 +78,9 @@ class Linker(Executor): (self._exists(path) and not self._is_link(path))): fullpath = os.path.expanduser(path) try: - if os.path.isdir(fullpath): + if os.path.islink(fullpath): + os.unlink(fullpath) + elif os.path.isdir(fullpath): shutil.rmtree(fullpath) else: os.remove(fullpath)