[core/lfs] Load correct old manifest file after aborted installation

If a user were to start and then abort an installation previously
we would have loaded the downloaded new manifest, rather than the
one of the installed version. By explicitly setting the version
we can avoid this.
This commit is contained in:
derrod 2020-04-24 06:26:45 +02:00
parent 78d745b03f
commit a59107e503
2 changed files with 11 additions and 3 deletions

View file

@ -312,7 +312,8 @@ class LegendaryCore:
old_manifest_data = f.read()
old_manifest = self.load_manfiest(old_manifest_data)
elif not disable_patching and not force and self.is_installed(game.app_name):
if old_bytes := self.lgd.get_manifest(game.app_name):
igame = self.get_installed_game(game.app_name)
if old_bytes := self.lgd.get_manifest(game.app_name, igame.version):
old_manifest = self.load_manfiest(old_bytes)
base_urls = list(game.base_urls) # copy list for manipulation

View file

@ -116,8 +116,15 @@ class LGDLFS:
open(os.path.join(self.path, 'assets.json'), 'w'),
indent=2, sort_keys=True)
def get_manifest(self, app_name):
def get_manifest(self, app_name, version=''):
if not version:
manifest_file = os.path.join(self.path, 'manifests', f'{app_name}.manifest')
else:
# if a version is specified load it from the versioned directory
fname = clean_filename(f'{app_name}_{version}')
manifest_file = os.path.join(self.path, 'manifests', 'old',
f'{fname}.manifest')
if os.path.exists(manifest_file):
return open(manifest_file, 'rb').read()
else: