Browse Source

fix CDNDepotFile.read() skipping chunks and returning bad data

pull/214/head
Rossen Georgiev 6 years ago
parent
commit
410756070a
  1. 10
      steam/client/cdn.py

10
steam/client/cdn.py

@ -314,7 +314,7 @@ class CDNDepotFile(DepotFile):
def read(self, length=-1): def read(self, length=-1):
"""Read bytes from the file """Read bytes from the file
:param length: number of bytes to read. Read the whole if not set :param length: number of bytes to read. Read the whole file if not set
:type length: int :type length: int
:returns: file data :returns: file data
:rtype: bytes :rtype: bytes
@ -337,12 +337,12 @@ class CDNDepotFile(DepotFile):
data = BytesIO() data = BytesIO()
start_offset = None start_offset = None
# Manifest orders the chunks in ascending order by offset # Manifest orders the chunks by offset in ascending order
for chunk in self.chunks: for chunk in self.chunks:
if chunk.offset >= end_offset: if chunk.offset >= end_offset:
break break
elif (chunk.offset <= self.offset < chunk.offset + chunk.cb_original elif (self.offset <= chunk.offset < end_offset
or chunk.offset < end_offset <= chunk.offset + chunk.cb_original): or self.offset < (chunk.offset + chunk.cb_original) <= end_offset):
if start_offset is None: if start_offset is None:
start_offset = chunk.offset start_offset = chunk.offset
data.write(self._get_chunk(chunk)) data.write(self._get_chunk(chunk))
@ -427,7 +427,7 @@ class CDNDepotManifest(DepotManifest):
# order chunks in ascending order by their offset # order chunks in ascending order by their offset
# required for CDNDepotFile # required for CDNDepotFile
for mapping in self.payload.mappings: for mapping in self.payload.mappings:
mapping.chunks.sort(key=lambda x: x.offset) mapping.chunks.sort(key=lambda x: x.offset, reverse=False)
class CDNClient(object): class CDNClient(object):

Loading…
Cancel
Save