@@ -453,6 +453,7 @@ class ZipInfo:
453453 'file_size' ,
454454 '_raw_time' ,
455455 '_end_offset' ,
456+ '_force_zip64' ,
456457 )
457458
458459 def __init__ (self , filename = "NoName" , date_time = (1980 ,1 ,1 ,0 ,0 ,0 )):
@@ -488,6 +489,7 @@ def __init__(self, filename="NoName", date_time=(1980,1,1,0,0,0)):
488489 self .compress_size = 0 # Size of the compressed file
489490 self .file_size = 0 # Size of the uncompressed file
490491 self ._end_offset = None # Start of the next local header or central directory
492+ self ._force_zip64 = None # Whether zip64 extension is forced
491493 # Other attributes are set by class ZipFile:
492494 # header_offset Byte offset to the file header
493495 # CRC CRC-32 of the uncompressed file
@@ -2202,6 +2204,7 @@ def open(self, name, mode="r", pwd=None, *, force_zip64=False):
22022204 zinfo = self .getinfo (name )
22032205
22042206 if mode == 'w' :
2207+ zinfo ._force_zip64 = force_zip64
22052208 return self ._open_to_write (zinfo , force_zip64 = force_zip64 )
22062209
22072210 if self ._writing :
@@ -2646,8 +2649,10 @@ def _write_end_record(self):
26462649 dosdate = (dt [0 ] - 1980 ) << 9 | dt [1 ] << 5 | dt [2 ]
26472650 dostime = dt [3 ] << 11 | dt [4 ] << 5 | (dt [5 ] // 2 )
26482651 extra = []
2649- if zinfo .file_size > ZIP64_LIMIT \
2650- or zinfo .compress_size > ZIP64_LIMIT :
2652+ if (zinfo ._force_zip64
2653+ or zinfo .file_size > ZIP64_LIMIT
2654+ or zinfo .compress_size > ZIP64_LIMIT
2655+ ):
26512656 extra .append (zinfo .file_size )
26522657 extra .append (zinfo .compress_size )
26532658 file_size = 0xffffffff
0 commit comments