Skip to content

Commit c443c60

Browse files
committed
FIX: add many iterables that sum length requires zip64 and allowzip64=False
FIX: add iterables that lengths requires zip64 and allowzip64=True
1 parent 7a1ca87 commit c443c60

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

zipstream/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,11 @@ def __write(self, filename=None, iterable=None, arcname=None, compress_type=None
324324
zinfo.compress_size = file_size
325325
zinfo.CRC = CRC
326326
zinfo.file_size = file_size
327+
if not filename:
328+
zip64 = zinfo.file_size > ZIP64_LIMIT or \
329+
zinfo.compress_size > ZIP64_LIMIT
330+
if zip64 and not self._allowZip64:
331+
raise zipfile.LargeZipFile("Filesize would require ZIP64 extensions")
327332
if not zip64 and self._allowZip64:
328333
if file_size > ZIP64_LIMIT:
329334
raise RuntimeError('File size has increased during compressing')
@@ -421,6 +426,8 @@ def __close(self):
421426
centDirOffset > ZIP64_LIMIT or
422427
centDirSize > ZIP64_LIMIT):
423428
# Need to write the ZIP64 end-of-archive records
429+
if not self._allowZip64:
430+
raise zipfile.LargeZipFile(" would require ZIP64 extensions")
424431
zip64endrec = struct.pack(
425432
structEndArchive64, stringEndArchive64,
426433
44, 45, 45, 0, 0, centDirCount, centDirCount,

0 commit comments

Comments
 (0)