]> git.ipfire.org Git - pakfire.git/commitdiff
Remove symlinks before extrating the new one.
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 3 Oct 2011 00:34:16 +0000 (02:34 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 3 Oct 2011 00:34:16 +0000 (02:34 +0200)
tarfile is not able to overwrite existing symlinks but we need
to take care of them that the destiation is correctly set.

python/pakfire/packages/file.py

index ed37fee5250eb1ea213388d01ba691c362e4beb3..6b5f22ea3ac52b9148b2cb8694a2057d43d70c5b 100644 (file)
@@ -96,9 +96,11 @@ class InnerTarFile(tarfile.TarFile):
                target = os.path.join(path, member.name)
 
                # Remove symlink targets, because tarfile cannot replace them.
-               if member.issym() and os.path.exists(target):
-                       print "unlinking", target
-                       os.unlink(target)
+               if member.issym():
+                       try:
+                               os.unlink(target)
+                       except OSError:
+                               pass
 
                # Extract file the normal way...
                try: