From 83e3af344f6db38d349f6a4bef32f10c6d92e0a0 Mon Sep 17 00:00:00 2001 From: derrod Date: Mon, 2 Nov 2020 14:58:23 +0100 Subject: [PATCH] [core/lfs] Remove unversioned local manifest saving/loading --- legendary/core.py | 3 --- legendary/lfs/lgndry.py | 16 ++++++---------- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/legendary/core.py b/legendary/core.py index 5bb177b..e4d2ea3 100644 --- a/legendary/core.py +++ b/legendary/core.py @@ -713,7 +713,6 @@ class LegendaryCore: self.log.info('Parsing game manifest...') new_manifest = self.load_manifest(new_manifest_data) self.log.debug(f'Base urls: {base_urls}') - self.lgd.save_manifest(game.app_name, new_manifest_data) # save manifest with version name as well for testing/downgrading/etc. self.lgd.save_manifest(game.app_name, new_manifest_data, version=new_manifest.meta.build_version) @@ -960,7 +959,6 @@ class LegendaryCore: # parse and save manifest to disk for verification step of import 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) install_size = sum(fm.file_size for fm in new_manifest.file_manifest_list.elements) @@ -1031,7 +1029,6 @@ class LegendaryCore: with open(manifest_filename, 'rb') as f: manifest_data = f.read() 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) # mark game as installed diff --git a/legendary/lfs/lgndry.py b/legendary/lfs/lgndry.py index 460fc13..7a960f5 100644 --- a/legendary/lfs/lgndry.py +++ b/legendary/lfs/lgndry.py @@ -31,7 +31,7 @@ class LGDLFS: self.config.optionxform = str # ensure folders exist. - for f in ['', 'manifests', 'metadata', 'tmp', 'manifests/old']: + for f in ['', 'manifests', 'metadata', 'tmp']: if not os.path.exists(os.path.join(self.path, f)): os.makedirs(os.path.join(self.path, f)) @@ -123,21 +123,17 @@ class LGDLFS: open(os.path.join(self.path, 'assets.json'), 'w'), indent=2, sort_keys=True) - def _get_manifest_filename(self, app_name, version=''): - if not version: - return 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}') - return os.path.join(self.path, 'manifests', 'old', f'{fname}.manifest') + def _get_manifest_filename(self, app_name, version): + fname = clean_filename(f'{app_name}_{version}') + return os.path.join(self.path, 'manifests', f'{fname}.manifest') - def load_manifest(self, app_name, version=''): + def load_manifest(self, app_name, version): 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): with open(self._get_manifest_filename(app_name, version), 'wb') as f: f.write(manifest_data)