From 0b19284142697a5d45fd24ac3e03620f7a1a969d Mon Sep 17 00:00:00 2001 From: Paul Sherwood Date: Sun, 3 Jul 2016 09:10:25 +0100 Subject: [PATCH] Try unlink, then remove --- ybd/utils.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ybd/utils.py b/ybd/utils.py index 0c2c6a6..a0fb086 100644 --- a/ybd/utils.py +++ b/ybd/utils.py @@ -167,7 +167,13 @@ def _process_tree(root, srcpath, destpath, actionfunc): path = re.search('/.*$', re.search('tmp[^/]+/.*$', destpath).group(0)).group(0) app.config['new-overlaps'] += [path] - os.remove(destpath) + try: + os.unlink(destpath) + except: + try: + os.remove(destpath) + except: + shutil.rmtree(destpath) # Ensure that the symlink target is a relative path target = os.readlink(srcpath)