From 2e2bb3ad416a125c022713570b5bb9b1fd715b71 Mon Sep 17 00:00:00 2001 From: derrod Date: Thu, 28 May 2020 23:05:36 +0200 Subject: [PATCH] [cli/core/models] Add install size to installed games --- legendary/cli.py | 9 ++++++++- legendary/core.py | 2 +- legendary/models/game.py | 4 +++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/legendary/cli.py b/legendary/cli.py index defafaa..bedf69a 100644 --- a/legendary/cli.py +++ b/legendary/cli.py @@ -150,7 +150,14 @@ class LegendaryCLI: print('\nInstalled games:') for game in games: - print(f' * {game.title} (App name: {game.app_name} | Version: {game.version})') + if game.install_size == 0: + logger.debug(f'Updating missing size for {game.app_name}') + m = self.core.load_manfiest(self.core.get_installed_manifest(game.app_name)[0]) + game.install_size = sum(fm.file_size for fm in m.file_manifest_list.elements) + self.core.install_game(game) + + print(f' * {game.title} (App name: {game.app_name} | Version: {game.version} | ' + f'{game.install_size / (1024*1024*1024):.02f} GiB)') if versions[game.app_name] != game.version: print(f' -> Update available! Installed: {game.version}, Latest: {versions[game.app_name]}') diff --git a/legendary/core.py b/legendary/core.py index 2f2f514..5fdf9cc 100644 --- a/legendary/core.py +++ b/legendary/core.py @@ -696,7 +696,7 @@ class LegendaryCore: install_path=install_path, executable=new_manifest.meta.launch_exe, launch_parameters=new_manifest.meta.launch_command, can_run_offline=offline == 'true', requires_ot=ot == 'true', - is_dlc=base_game is not None) + is_dlc=base_game is not None, install_size=anlres.install_size) return dlm, anlres, igame diff --git a/legendary/models/game.py b/legendary/models/game.py index 14afae0..a3205dd 100644 --- a/legendary/models/game.py +++ b/legendary/models/game.py @@ -79,7 +79,7 @@ class InstalledGame: def __init__(self, app_name='', title='', version='', manifest_path='', base_urls=None, install_path='', executable='', launch_parameters='', prereq_info=None, can_run_offline=False, requires_ot=False, is_dlc=False, save_path=None, - needs_verification=False): + needs_verification=False, install_size=0): self.app_name = app_name self.title = title self.version = version @@ -95,6 +95,7 @@ class InstalledGame: self.is_dlc = is_dlc self.save_path = save_path self.needs_verification = needs_verification + self.install_size = install_size @classmethod def from_json(cls, json): @@ -115,6 +116,7 @@ class InstalledGame: tmp.is_dlc = json.get('is_dlc', False) tmp.save_path = json.get('save_path', None) tmp.needs_verification = json.get('needs_verification', None) + tmp.install_size = json.get('install_size', 0) return tmp