delete(): Don't crash on removing symlinks to directories
authorThomas Jarosch <thomas.jarosch@intra2net.com>
Wed, 15 Jun 2016 06:42:02 +0000 (08:42 +0200)
committerThomas Jarosch <thomas.jarosch@intra2net.com>
Wed, 15 Jun 2016 06:42:02 +0000 (08:42 +0200)
shutil.rmtree() will refuse to follow symlinks.
-> just call os.unlink() for symlinks.

deltatar/deltatar.py

index ff8292a..9bd6927 100644 (file)
@@ -1449,7 +1449,7 @@ class RestoreHelper(object):
         parent_dir = os.path.dirname(path)
         parent_dir_mtime = int(os.stat(parent_dir).st_mtime)
 
-        if os.path.isdir(path):
+        if os.path.isdir(path) and not os.path.islink(path):
             shutil.rmtree(path)
         else:
             os.unlink(path)