Skip to content

Commit

Permalink
FIX: add many iterables that sum length requires zip64 and allowzip64…
Browse files Browse the repository at this point in the history
…=False

FIX: add iterables that lengths requires zip64 and allowzip64=True
  • Loading branch information
uchood committed Jan 28, 2018
1 parent 7a1ca87 commit c443c60
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions zipstream/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,11 @@ def __write(self, filename=None, iterable=None, arcname=None, compress_type=None
zinfo.compress_size = file_size
zinfo.CRC = CRC
zinfo.file_size = file_size
if not filename:
zip64 = zinfo.file_size > ZIP64_LIMIT or \
zinfo.compress_size > ZIP64_LIMIT
if zip64 and not self._allowZip64:
raise zipfile.LargeZipFile("Filesize would require ZIP64 extensions")
if not zip64 and self._allowZip64:
if file_size > ZIP64_LIMIT:
raise RuntimeError('File size has increased during compressing')
Expand Down Expand Up @@ -421,6 +426,8 @@ def __close(self):
centDirOffset > ZIP64_LIMIT or
centDirSize > ZIP64_LIMIT):
# Need to write the ZIP64 end-of-archive records
if not self._allowZip64:
raise zipfile.LargeZipFile(" would require ZIP64 extensions")
zip64endrec = struct.pack(
structEndArchive64, stringEndArchive64,
44, 45, 45, 0, 0, centDirCount, centDirCount,
Expand Down

0 comments on commit c443c60

Please sign in to comment.