From fadaf794d4ef8a1b8a15921b781c5e3f4bd2eba4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eray=20=C3=96zkural?= Date: Tue, 20 Dec 2005 15:53:06 +0000 Subject: [PATCH] fix: handle the case the previous file used to be a directory separately, baselayout failed without this --- pisi/archive.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pisi/archive.py b/pisi/archive.py index ec86771b..2fc08323 100644 --- a/pisi/archive.py +++ b/pisi/archive.py @@ -15,6 +15,7 @@ # standard library modules import os import stat +import shutil import tarfile import zipfile @@ -179,16 +180,18 @@ class ArchiveZip(ArchiveBase): perm |= 0x00000100 os.chmod(d, perm) continue - + # check that output dir is present util.check_dir(os.path.dirname(ofile)) # remove output file we might be overwriting. # (also check for islink? for broken symlinks...) - if os.path.exists(ofile) or os.path.islink(ofile): + if os.path.isfile(ofile) or os.path.islink(ofile): os.remove(ofile) - + if info.external_attr == self.symmagic: + if os.path.isdir(ofile): + shutil.rmtree(ofile) # a rare case, the file used to be a dir, now it is a symlink! target = zip_obj.read(info.filename) os.symlink(target, ofile) else: