From: Michael Tremer Date: Mon, 3 Oct 2011 00:34:16 +0000 (+0200) Subject: Remove symlinks before extrating the new one. X-Git-Tag: 0.9.11~9 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1103249222acaf0bacd93967c91363ba957828fa;p=pakfire.git Remove symlinks before extrating the new one. tarfile is not able to overwrite existing symlinks but we need to take care of them that the destiation is correctly set. --- diff --git a/python/pakfire/packages/file.py b/python/pakfire/packages/file.py index ed37fee52..6b5f22ea3 100644 --- a/python/pakfire/packages/file.py +++ b/python/pakfire/packages/file.py @@ -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: