Fix creation of empty dorectories in zip files

This commit is contained in:
Kovid Goyal 2011-06-07 09:49:33 -06:00
parent 6dac26d3d2
commit 41841f2e66
2 changed files with 5 additions and 3 deletions

View File

@ -379,7 +379,7 @@ class Win32Freeze(Command, WixMixIn):
name = '%s-portable-%s.zip'%(__appname__, __version__)
with zipfile.ZipFile(self.j('dist', name), 'w', zipfile.ZIP_DEFLATED) as zf:
self.add_dir_to_zip(zf, base)
self.add_dir_to_zip(zf, base, 'Calibre Portable')
def add_dir_to_zip(self, zf, path, prefix=''):
'''
@ -387,7 +387,7 @@ class Win32Freeze(Command, WixMixIn):
'''
if prefix:
zi = zipfile.ZipInfo(prefix+'/')
zi.external_attr = 0700 << 16
zi.external_attr = 16
zf.writestr(zi, '')
cwd = os.path.abspath(os.getcwd())
try:

View File

@ -1297,7 +1297,9 @@ class ZipFile:
Add a directory recursively to the zip file with an optional prefix.
'''
if prefix:
self.writestr(prefix+'/', '', 0700)
zi = ZipInfo(prefix+'/')
zi.external_attr = 16
self.writestr(zi, '')
cwd = os.path.abspath(os.getcwd())
try:
os.chdir(path)