mirror of
https://github.com/olivierkes/manuskript.git
synced 2024-05-10 16:02:33 +12:00
Directory entries in ZIP break loading code
While tackling issue #529, I stumbled across the odd behaviour that re-compressing the archive with 7-Zip broke what should be a valid Manuskript project. After investigation it turned out that the code that loads the texts sensibly expects there to only be files tracked in the files dictionary. It is completely valid for a zip file to contain entries describing the contained directories. The logical fix is to simply avoid adding these directory entries to our files dictionary in the first place.
This commit is contained in:
parent
dd56797cd7
commit
33ac127173
|
@ -178,7 +178,10 @@ def loadFilesFromZip(zipname):
|
|||
zf = zipfile.ZipFile(zipname)
|
||||
files = {}
|
||||
for f in zf.namelist():
|
||||
files[os.path.normpath(f)] = zf.read(f)
|
||||
# Some archiving programs (e.g. 7-Zip) also store entries for the directories when
|
||||
# creating an archive. We have no use for these entries; skip them entirely.
|
||||
if f[-1:] != '/':
|
||||
files[os.path.normpath(f)] = zf.read(f)
|
||||
return files
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue