[cli/core/models] Add install size to installed games

This commit is contained in:
derrod 2020-05-28 23:05:36 +02:00
parent 5d4d46f7ea
commit 2e2bb3ad41
3 changed files with 12 additions and 3 deletions

View file

@ -150,7 +150,14 @@ class LegendaryCLI:
print('\nInstalled games:') print('\nInstalled games:')
for game in 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: if versions[game.app_name] != game.version:
print(f' -> Update available! Installed: {game.version}, Latest: {versions[game.app_name]}') print(f' -> Update available! Installed: {game.version}, Latest: {versions[game.app_name]}')

View file

@ -696,7 +696,7 @@ class LegendaryCore:
install_path=install_path, executable=new_manifest.meta.launch_exe, install_path=install_path, executable=new_manifest.meta.launch_exe,
launch_parameters=new_manifest.meta.launch_command, launch_parameters=new_manifest.meta.launch_command,
can_run_offline=offline == 'true', requires_ot=ot == 'true', 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 return dlm, anlres, igame

View file

@ -79,7 +79,7 @@ class InstalledGame:
def __init__(self, app_name='', title='', version='', manifest_path='', base_urls=None, def __init__(self, app_name='', title='', version='', manifest_path='', base_urls=None,
install_path='', executable='', launch_parameters='', prereq_info=None, install_path='', executable='', launch_parameters='', prereq_info=None,
can_run_offline=False, requires_ot=False, is_dlc=False, save_path=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.app_name = app_name
self.title = title self.title = title
self.version = version self.version = version
@ -95,6 +95,7 @@ class InstalledGame:
self.is_dlc = is_dlc self.is_dlc = is_dlc
self.save_path = save_path self.save_path = save_path
self.needs_verification = needs_verification self.needs_verification = needs_verification
self.install_size = install_size
@classmethod @classmethod
def from_json(cls, json): def from_json(cls, json):
@ -115,6 +116,7 @@ class InstalledGame:
tmp.is_dlc = json.get('is_dlc', False) tmp.is_dlc = json.get('is_dlc', False)
tmp.save_path = json.get('save_path', None) tmp.save_path = json.get('save_path', None)
tmp.needs_verification = json.get('needs_verification', None) tmp.needs_verification = json.get('needs_verification', None)
tmp.install_size = json.get('install_size', 0)
return tmp return tmp