[core/lfs] Include platform in saved manifest name

This commit is contained in:
derrod 2021-12-01 21:26:21 +01:00
parent 081cca2c19
commit 8c56bd93d5
2 changed files with 24 additions and 14 deletions

View file

@ -985,7 +985,7 @@ class LegendaryCore:
def get_installed_manifest(self, app_name): def get_installed_manifest(self, app_name):
igame = self._get_installed_game(app_name) igame = self._get_installed_game(app_name)
old_bytes = self.lgd.load_manifest(app_name, igame.version) old_bytes = self.lgd.load_manifest(app_name, igame.version, igame.platform)
return old_bytes, igame.base_urls return old_bytes, igame.base_urls
def get_cdn_urls(self, game, platform='Windows'): def get_cdn_urls(self, game, platform='Windows'):
@ -1048,7 +1048,7 @@ class LegendaryCore:
force: bool = False, disable_patching: bool = False, force: bool = False, disable_patching: bool = False,
game_folder: str = '', override_manifest: str = '', game_folder: str = '', override_manifest: str = '',
override_old_manifest: str = '', override_base_url: str = '', override_old_manifest: str = '', override_base_url: str = '',
platform: str = '', file_prefix_filter: list = None, platform: str = 'Windows', file_prefix_filter: list = None,
file_exclude_filter: list = None, file_install_tag: list = None, file_exclude_filter: list = None, file_install_tag: list = None,
dl_optimizations: bool = False, dl_timeout: int = 10, dl_optimizations: bool = False, dl_timeout: int = 10,
repair: bool = False, repair_use_latest: bool = False, repair: bool = False, repair_use_latest: bool = False,
@ -1092,7 +1092,8 @@ class LegendaryCore:
self.log.debug(f'Base urls: {base_urls}') self.log.debug(f'Base urls: {base_urls}')
# save manifest with version name as well for testing/downgrading/etc. # save manifest with version name as well for testing/downgrading/etc.
self.lgd.save_manifest(game.app_name, new_manifest_data, self.lgd.save_manifest(game.app_name, new_manifest_data,
version=new_manifest.meta.build_version) version=new_manifest.meta.build_version,
platform=platform)
# check if we should use a delta manifest or not # check if we should use a delta manifest or not
disable_delta = disable_delta or ((override_old_manifest or override_manifest) and not override_delta_manifest) disable_delta = disable_delta or ((override_old_manifest or override_manifest) and not override_delta_manifest)
@ -1365,7 +1366,7 @@ class LegendaryCore:
igame.prereq_info['installed'] = True igame.prereq_info['installed'] = True
self.lgd.set_installed_game(app_name, igame) self.lgd.set_installed_game(app_name, igame)
def import_game(self, game: Game, app_path: str, egl_guid='') -> (Manifest, InstalledGame): def import_game(self, game: Game, app_path: str, egl_guid='', platform='Windows') -> (Manifest, InstalledGame):
needs_verify = True needs_verify = True
manifest_data = None manifest_data = None
@ -1414,7 +1415,7 @@ class LegendaryCore:
# parse and save manifest to disk for verification step of import # parse and save manifest to disk for verification step of import
new_manifest = self.load_manifest(manifest_data) new_manifest = self.load_manifest(manifest_data)
self.lgd.save_manifest(game.app_name, manifest_data, self.lgd.save_manifest(game.app_name, manifest_data,
version=new_manifest.meta.build_version) version=new_manifest.meta.build_version, platform=platform)
install_size = sum(fm.file_size for fm in new_manifest.file_manifest_list.elements) install_size = sum(fm.file_size for fm in new_manifest.file_manifest_list.elements)
prereq = None prereq = None
@ -1428,7 +1429,8 @@ class LegendaryCore:
install_path=app_path, version=new_manifest.meta.build_version, is_dlc=game.is_dlc, install_path=app_path, version=new_manifest.meta.build_version, is_dlc=game.is_dlc,
executable=new_manifest.meta.launch_exe, can_run_offline=offline == 'true', executable=new_manifest.meta.launch_exe, can_run_offline=offline == 'true',
launch_parameters=new_manifest.meta.launch_command, requires_ot=ot == 'true', launch_parameters=new_manifest.meta.launch_command, requires_ot=ot == 'true',
needs_verification=needs_verify, install_size=install_size, egl_guid=egl_guid) needs_verification=needs_verify, install_size=install_size, egl_guid=egl_guid,
platform=platform)
return new_manifest, igame return new_manifest, igame
@ -1485,7 +1487,8 @@ class LegendaryCore:
manifest_data = f.read() manifest_data = f.read()
new_manifest = self.load_manifest(manifest_data) new_manifest = self.load_manifest(manifest_data)
self.lgd.save_manifest(lgd_igame.app_name, manifest_data, self.lgd.save_manifest(lgd_igame.app_name, manifest_data,
version=new_manifest.meta.build_version) version=new_manifest.meta.build_version,
platform='Windows')
# transfer install tag choices to config # transfer install tag choices to config
if lgd_igame.install_tags: if lgd_igame.install_tags:

View file

@ -195,18 +195,25 @@ class LGDLFS:
open(os.path.join(self.path, 'assets.json'), 'w'), open(os.path.join(self.path, 'assets.json'), 'w'),
indent=2, sort_keys=True) indent=2, sort_keys=True)
def _get_manifest_filename(self, app_name, version): def _get_manifest_filename(self, app_name, version, platform=None):
fname = clean_filename(f'{app_name}_{version}') if platform:
fname = clean_filename(f'{app_name}_{platform}_{version}')
else:
fname = clean_filename(f'{app_name}_{version}')
return os.path.join(self.path, 'manifests', f'{fname}.manifest') return os.path.join(self.path, 'manifests', f'{fname}.manifest')
def load_manifest(self, app_name, version): def load_manifest(self, app_name, version, platform='Windows'):
try: try:
return open(self._get_manifest_filename(app_name, version), 'rb').read() return open(self._get_manifest_filename(app_name, version, platform), 'rb').read()
except FileNotFoundError: # all other errors should propagate except FileNotFoundError: # all other errors should propagate
return None self.log.debug(f'Loading manifest failed, retrying without platform in filename...')
try:
return open(self._get_manifest_filename(app_name, version), 'rb').read()
except FileNotFoundError: # all other errors should propagate
return None
def save_manifest(self, app_name, manifest_data, version): def save_manifest(self, app_name, manifest_data, version, platform='Windows'):
with open(self._get_manifest_filename(app_name, version), 'wb') as f: with open(self._get_manifest_filename(app_name, version, platform), 'wb') as f:
f.write(manifest_data) f.write(manifest_data)
def get_game_meta(self, app_name): def get_game_meta(self, app_name):