mirror of
https://github.com/derrod/legendary.git
synced 2024-12-22 17:55:27 +00:00
[cli/core/lfs] Add update check for installed overlay
This commit is contained in:
parent
efaf25b9d9
commit
8d71df0cc4
|
@ -2474,6 +2474,11 @@ def main():
|
||||||
|
|
||||||
print(f'\n- Download URL: {update_info["downloads"][dl_platform]}')
|
print(f'\n- Download URL: {update_info["downloads"][dl_platform]}')
|
||||||
|
|
||||||
|
if not disable_update_message and cli.core.overlay_update_available:
|
||||||
|
version_info = cli.core.lgd.get_cached_overlay_version()
|
||||||
|
print(f'\nEOS Overlay update available ({version_info["data"]["buildVersion"]}).')
|
||||||
|
print('Run "legendary eos-overlay update" to update to the latest version.')
|
||||||
|
|
||||||
cli.core.exit()
|
cli.core.exit()
|
||||||
ql.stop()
|
ql.stop()
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
|
@ -89,6 +89,7 @@ class LegendaryCore:
|
||||||
self.update_available = False
|
self.update_available = False
|
||||||
self.force_show_update = False
|
self.force_show_update = False
|
||||||
self.webview_killswitch = False
|
self.webview_killswitch = False
|
||||||
|
self.overlay_update_available = False
|
||||||
self.logged_in = False
|
self.logged_in = False
|
||||||
|
|
||||||
def auth(self, username, password):
|
def auth(self, username, password):
|
||||||
|
@ -203,6 +204,13 @@ class LegendaryCore:
|
||||||
else:
|
else:
|
||||||
self.apply_lgd_config()
|
self.apply_lgd_config()
|
||||||
|
|
||||||
|
# check for overlay updates
|
||||||
|
if self.is_overlay_installed():
|
||||||
|
try:
|
||||||
|
self.check_for_overlay_updates()
|
||||||
|
except Exception as e:
|
||||||
|
self.log.warning(f'Checking for EOS Overlay updates failed: {e!r}')
|
||||||
|
|
||||||
if self.lgd.userdata['expires_at'] and not force_refresh:
|
if self.lgd.userdata['expires_at'] and not force_refresh:
|
||||||
dt_exp = datetime.fromisoformat(self.lgd.userdata['expires_at'][:-1])
|
dt_exp = datetime.fromisoformat(self.lgd.userdata['expires_at'][:-1])
|
||||||
dt_now = datetime.utcnow()
|
dt_now = datetime.utcnow()
|
||||||
|
@ -1677,6 +1685,23 @@ class LegendaryCore:
|
||||||
def egl_sync_enabled(self):
|
def egl_sync_enabled(self):
|
||||||
return self.lgd.config.getboolean('Legendary', 'egl_sync', fallback=False)
|
return self.lgd.config.getboolean('Legendary', 'egl_sync', fallback=False)
|
||||||
|
|
||||||
|
def check_for_overlay_updates(self):
|
||||||
|
cached = self.lgd.get_cached_overlay_version()
|
||||||
|
version_info = cached['data']
|
||||||
|
if not version_info or (datetime.now().timestamp() - cached['last_update']) > 24*3600:
|
||||||
|
# start anoymous session for update check if we're not logged in yet
|
||||||
|
if not self.logged_in:
|
||||||
|
self.egs.start_session(client_credentials=True)
|
||||||
|
|
||||||
|
manifest_response = self.egs.get_game_manifest(EOSOverlayApp.namespace,
|
||||||
|
EOSOverlayApp.catalog_item_id,
|
||||||
|
EOSOverlayApp.app_name)
|
||||||
|
version_info = manifest_response['elements'][0]
|
||||||
|
self.lgd.set_cached_overlay_version(version_info)
|
||||||
|
|
||||||
|
installed = self.lgd.get_overlay_install_info()
|
||||||
|
self.overlay_update_available = version_info['buildVersion'] != installed.version
|
||||||
|
|
||||||
def is_overlay_installed(self):
|
def is_overlay_installed(self):
|
||||||
return self.lgd.get_overlay_install_info() is not None
|
return self.lgd.get_overlay_install_info() is not None
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,8 @@ class LGDLFS:
|
||||||
self._game_metadata = dict()
|
self._game_metadata = dict()
|
||||||
# Legendary update check info
|
# Legendary update check info
|
||||||
self._update_info = None
|
self._update_info = None
|
||||||
|
# EOS Overlay update check info
|
||||||
|
self._overlay_update_info = None
|
||||||
# Config with game specific settings (e.g. start parameters, env variables)
|
# Config with game specific settings (e.g. start parameters, env variables)
|
||||||
self.config = LGDConf(comment_prefixes='/', allow_no_value=True)
|
self.config = LGDConf(comment_prefixes='/', allow_no_value=True)
|
||||||
|
|
||||||
|
@ -364,6 +366,25 @@ class LGDLFS:
|
||||||
open(os.path.join(self.path, 'tmp', f'{app_name}.json'), 'w'),
|
open(os.path.join(self.path, 'tmp', f'{app_name}.json'), 'w'),
|
||||||
indent=2, sort_keys=True)
|
indent=2, sort_keys=True)
|
||||||
|
|
||||||
|
def get_cached_overlay_version(self):
|
||||||
|
if self._overlay_update_info:
|
||||||
|
return self._overlay_update_info
|
||||||
|
|
||||||
|
try:
|
||||||
|
self._overlay_update_info = json.load(open(
|
||||||
|
os.path.join(self.path, 'overlay_version.json')))
|
||||||
|
except Exception as e:
|
||||||
|
self.log.debug(f'Failed to load cached Overlay update data: {e!r}')
|
||||||
|
self._overlay_update_info = dict(last_update=0, data=None)
|
||||||
|
|
||||||
|
return self._overlay_update_info
|
||||||
|
|
||||||
|
def set_cached_overlay_version(self, version_data):
|
||||||
|
self._overlay_update_info = dict(last_update=time(), data=version_data)
|
||||||
|
json.dump(self._overlay_update_info,
|
||||||
|
open(os.path.join(self.path, 'overlay_version.json'), 'w'),
|
||||||
|
indent=2, sort_keys=True)
|
||||||
|
|
||||||
def get_overlay_install_info(self):
|
def get_overlay_install_info(self):
|
||||||
try:
|
try:
|
||||||
data = json.load(open(os.path.join(self.path, f'overlay_install.json')))
|
data = json.load(open(os.path.join(self.path, f'overlay_install.json')))
|
||||||
|
|
Loading…
Reference in a new issue