Browse Source

cdn: add decrypt param to get_manifests() and dont iter files on encrypted depots

pull/214/head
Rossen Georgiev 6 years ago
parent
commit
b768304435
  1. 9
      steam/client/cdn.py
  2. 21
      steam/core/manifest.py

9
steam/client/cdn.py

@ -413,7 +413,7 @@ class CDNDepotManifest(DepotManifest):
if self.name: if self.name:
params = repr(self.name) + ', ' + params params = repr(self.name) + ', ' + params
if self.metadata.filenames_encrypted: if self.filenames_encrypted:
params += ', filenames_encrypted=True' params += ', filenames_encrypted=True'
return "<%s(%s)>" % ( return "<%s(%s)>" % (
@ -658,7 +658,7 @@ class CDNClient(object):
self.app_depots[app_id] = self.steam.get_product_info([app_id])['apps'][app_id]['depots'] self.app_depots[app_id] = self.steam.get_product_info([app_id])['apps'][app_id]['depots']
return self.app_depots[app_id] return self.app_depots[app_id]
def get_manifests(self, app_id, branch='public', password=None, filter_func=None): def get_manifests(self, app_id, branch='public', password=None, filter_func=None, decrypt=True):
"""Get a list of CDNDepotManifest for app """Get a list of CDNDepotManifest for app
:param app_id: App ID :param app_id: App ID
@ -694,8 +694,8 @@ class CDNClient(object):
if (app_id, branch) not in self.beta_passwords: if (app_id, branch) not in self.beta_passwords:
raise SteamError("Incorrect password for branch %r" % branch) raise SteamError("Incorrect password for branch %r" % branch)
def async_fetch_manifest(app_id, depot_id, manifest_gid, name): def async_fetch_manifest(app_id, depot_id, manifest_gid, decrypt, name):
manifest = self.get_manifest(app_id, depot_id, manifest_gid) manifest = self.get_manifest(app_id, depot_id, manifest_gid, decrypt)
manifest.name = name manifest.name = name
return manifest return manifest
@ -743,6 +743,7 @@ class CDNClient(object):
app_id, app_id,
depot_id, depot_id,
manifest_gid, manifest_gid,
decrypt,
depot_info['name'], depot_info['name'],
)) ))

21
steam/core/manifest.py

@ -159,6 +159,11 @@ class DepotManifest(object):
""":type: int""" """:type: int"""
return self.metadata.cb_disk_compressed return self.metadata.cb_disk_compressed
@property
def filenames_encrypted(self):
""":type: bool"""
return self.metadata.filenames_encrypted
def decrypt_filenames(self, depot_key): def decrypt_filenames(self, depot_key):
"""Decrypt all filenames in the manifest """Decrypt all filenames in the manifest
@ -256,19 +261,21 @@ class DepotManifest(object):
return data.getvalue() return data.getvalue()
def __iter__(self): def __iter__(self):
for mapping in self.payload.mappings: if not self.filenames_encrypted:
yield self.DepotFileClass(self, mapping) for mapping in self.payload.mappings:
yield self.DepotFileClass(self, mapping)
def iter_files(self, pattern=None): def iter_files(self, pattern=None):
""" """
:param pattern: unix shell wildcard pattern, see :func:`.fnmatch` :param pattern: unix shell wildcard pattern, see :func:`.fnmatch`
:type pattern: str :type pattern: str
""" """
for mapping in self.payload.mappings: if not self.filenames_encrypted:
if (pattern is not None for mapping in self.payload.mappings:
and not fnmatch(mapping.filename.rstrip('\x00 \n\t'), pattern)): if (pattern is not None
continue and not fnmatch(mapping.filename.rstrip('\x00 \n\t'), pattern)):
yield self.DepotFileClass(self, mapping) continue
yield self.DepotFileClass(self, mapping)
def __len__(self): def __len__(self):
return len(self.payload.mappings) return len(self.payload.mappings)

Loading…
Cancel
Save