mirror of
https://github.com/derrod/legendary.git
synced 2024-12-22 17:55:27 +00:00
[cli/lfs] Prune game metadata that's no longer needed
This commit is contained in:
parent
8c002a76e0
commit
0ef916e9c5
|
@ -394,9 +394,28 @@ class LegendaryCore:
|
|||
|
||||
if not platform_override:
|
||||
self.update_aliases(force=meta_updated)
|
||||
if meta_updated:
|
||||
self._prune_metadata()
|
||||
|
||||
return _ret, _dlc
|
||||
|
||||
def _prune_metadata(self):
|
||||
# compile list of games without assets, then delete their metadata
|
||||
available_assets = {i.app_name for i in self.get_assets()}
|
||||
|
||||
for app_name in self.lgd.get_game_app_names():
|
||||
if app_name in available_assets:
|
||||
continue
|
||||
# if metadata is still used by an install hold-off on deleting it
|
||||
if self.is_installed(app_name):
|
||||
continue
|
||||
game = self.get_game(app_name)
|
||||
# Origin games etc.
|
||||
if game.third_party_store:
|
||||
continue
|
||||
self.log.debug(f'Removing old/unused metadata for "{app_name}"')
|
||||
self.lgd.delete_game_meta(app_name)
|
||||
|
||||
def get_non_asset_library_items(self, force_refresh=False,
|
||||
skip_ue=True) -> (List[Game], Dict[str, List[Game]]):
|
||||
"""
|
||||
|
|
|
@ -230,6 +230,9 @@ class LGDLFS:
|
|||
else:
|
||||
raise ValueError(f'Game {app_name} does not exist in metadata DB!')
|
||||
|
||||
def get_game_app_names(self):
|
||||
return sorted(self._game_metadata.keys())
|
||||
|
||||
def get_tmp_path(self):
|
||||
return os.path.join(self.path, 'tmp')
|
||||
|
||||
|
|
Loading…
Reference in a new issue