From 1103249222acaf0bacd93967c91363ba957828fa Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Mon, 3 Oct 2011 02:34:16 +0200 Subject: [PATCH] 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. --- python/pakfire/packages/file.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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: -- 2.39.5