From b5bfad57190ce30825c71369f3fc9adca2ebc28b Mon Sep 17 00:00:00 2001 From: tomkat83 Date: Wed, 9 Mar 2016 15:53:46 +0100 Subject: [PATCH] Fix library sync paused --- resources/lib/entrypoint.py | 11 ++++++++++- resources/lib/userclient.py | 1 + service.py | 3 --- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/resources/lib/entrypoint.py b/resources/lib/entrypoint.py index 532fb52b..978aa85f 100644 --- a/resources/lib/entrypoint.py +++ b/resources/lib/entrypoint.py @@ -421,8 +421,17 @@ def switchPlexUser(): # Pause library sync thread - user needs to be auth in order to sync utils.window('suspend_LibraryThread', value='true') # Wait to ensure that any sync already going on has finished + counter = 0 while utils.window('emby_dbScan') == 'true': - xbmc.sleep(1000) + if counter > 100: + # Something went wrong, aborting + # Resuming threads, just in case + utils.window('suspend_LibraryThread', clear=True) + # Abort reConnection + return + counter += 1 + xbmc.sleep(50) + # Log out currently signed in user: utils.window('emby_serverStatus', value="401") # Request lib sync to get user view data (e.g. watched/unwatched) diff --git a/resources/lib/userclient.py b/resources/lib/userclient.py index 16a93d48..ccac74fb 100644 --- a/resources/lib/userclient.py +++ b/resources/lib/userclient.py @@ -442,6 +442,7 @@ class UserClient(threading.Thread): # to authenticate the user self.auth = False if self.authenticate(): + # Successfully authenticated and loaded a user log("Current user: %s" % self.currUser, 1) log("Current userId: %s" % self.currUserId, 1) log("Current accessToken: xxxx", 1) diff --git a/service.py b/service.py index c928003f..0eda6df4 100644 --- a/service.py +++ b/service.py @@ -254,9 +254,6 @@ class Service(): log("Server is online and ready.", 1) window('emby_online', value="true") - # Start library sync thread in a suspended mode - # until signed in - utils.window('suspend_LibraryThread', value="true") # Start the userclient thread if not self.userclient_running: self.userclient_running = True