Guard against use of sync_local_library when the user is not logged in.

Let's not take an exception for this. It happens on each Lutris startup, if you aren't logged in already.
This commit is contained in:
Daniel Johnson 2024-03-06 19:40:04 -05:00
parent 1f1f00d345
commit 63a2f110df
2 changed files with 6 additions and 4 deletions

View file

@ -237,10 +237,10 @@ class LutrisWindow(Gtk.ApplicationWindow, DialogLaunchUIDelegate, DialogInstallU
if value.accel:
app.add_accelerator(value.accel, "win." + name)
def sync_library(self):
def sync_library(self, force=False):
"""Tasks that can be run after the UI has been initialized."""
if settings.read_setting("library_sync_enabled"):
AsyncCall(sync_local_library, None)
AsyncCall(sync_local_library, None, force=force)
def update_action_state(self):
"""This invokes the functions to update the enabled states of all the actions
@ -844,8 +844,7 @@ class LutrisWindow(Gtk.ApplicationWindow, DialogLaunchUIDelegate, DialogInstallU
return True
def on_lutris_account_connected(self):
if settings.read_bool_setting("library_sync_enabled"):
AsyncCall(sync_local_library, None, force=True)
self.sync_library(force=True)
def on_local_library_updated(self):
self.redraw_view()

View file

@ -54,6 +54,9 @@ def sync_local_library(force: bool = False) -> None:
local_library = get_local_library()
local_library_updates = get_local_library(since=since)
credentials = read_api_key()
if not credentials:
return
url = LIBRARY_URL
if since:
url += "?since=%s" % since