mirror of
https://github.com/python/cpython.git
synced 2025-10-17 04:08:28 +00:00
GH-128131: Completely support random read access of uncompressed unencrypted files in ZipFile (#128143)
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com> Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
This commit is contained in:
parent
ed6934e71e
commit
dda02eb7be
3 changed files with 88 additions and 1 deletions
|
@ -1184,13 +1184,15 @@ class ZipExtFile(io.BufferedIOBase):
|
|||
self._offset = buff_offset
|
||||
read_offset = 0
|
||||
# Fast seek uncompressed unencrypted file
|
||||
elif self._compress_type == ZIP_STORED and self._decrypter is None and read_offset > 0:
|
||||
elif self._compress_type == ZIP_STORED and self._decrypter is None and read_offset != 0:
|
||||
# disable CRC checking after first seeking - it would be invalid
|
||||
self._expected_crc = None
|
||||
# seek actual file taking already buffered data into account
|
||||
read_offset -= len(self._readbuffer) - self._offset
|
||||
self._fileobj.seek(read_offset, os.SEEK_CUR)
|
||||
self._left -= read_offset
|
||||
self._compress_left -= read_offset
|
||||
self._eof = self._left <= 0
|
||||
read_offset = 0
|
||||
# flush read buffer
|
||||
self._readbuffer = b''
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue