fix: handle the case the previous file used to be a directory separately, baselayout failed without this
This commit is contained in:
+4
-1
@@ -15,6 +15,7 @@
|
|||||||
# standard library modules
|
# standard library modules
|
||||||
import os
|
import os
|
||||||
import stat
|
import stat
|
||||||
|
import shutil
|
||||||
import tarfile
|
import tarfile
|
||||||
import zipfile
|
import zipfile
|
||||||
|
|
||||||
@@ -185,10 +186,12 @@ class ArchiveZip(ArchiveBase):
|
|||||||
|
|
||||||
# remove output file we might be overwriting.
|
# remove output file we might be overwriting.
|
||||||
# (also check for islink? for broken symlinks...)
|
# (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)
|
os.remove(ofile)
|
||||||
|
|
||||||
if info.external_attr == self.symmagic:
|
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)
|
target = zip_obj.read(info.filename)
|
||||||
os.symlink(target, ofile)
|
os.symlink(target, ofile)
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user