From cc3c55e038176d1edaaad2b0391d6b0241d5d6ab Mon Sep 17 00:00:00 2001 From: tomkat83 Date: Thu, 3 Mar 2016 09:35:35 +0100 Subject: [PATCH] Wait for lib sync to finish when switching user --- resources/lib/entrypoint.py | 5 +++-- resources/lib/librarysync.py | 7 ------- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/resources/lib/entrypoint.py b/resources/lib/entrypoint.py index b55ca4d2..aac8759a 100644 --- a/resources/lib/entrypoint.py +++ b/resources/lib/entrypoint.py @@ -364,8 +364,9 @@ def switchPlexUser(): "Plex home user switch requested", 0) # Pause library sync thread - user needs to be auth in order to sync utils.window('suspend_LibraryThread', value='true') - # Wait 1 second to ensure that library thread is indeed suspended - xbmc.sleep(1000) + # Wait to ensure that any sync already going on has finished + while utils.window('emby_dbScan' == 'true'): + xbmc.sleep(1000) # 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/librarysync.py b/resources/lib/librarysync.py index da7098c1..ddd67512 100644 --- a/resources/lib/librarysync.py +++ b/resources/lib/librarysync.py @@ -421,7 +421,6 @@ class LibrarySync(Thread): # Get current media folders from emby database view = emby_db.getView_byId(folderid) - self.logMsg("playlist: %s, nodes: %s, sorted_views: %s, folderid: %s, foldername: %s, viewtype: %s" % (playlists, nodes, sorted_views, folderid, foldername, viewtype)) try: current_viewname = view[0] current_viewtype = view[1] @@ -1228,12 +1227,6 @@ class LibrarySync(Thread): log('Running automatic full lib scan', 0) self.fullSync(manualrun=True) window('emby_dbScan', clear=True) - # Update views / PMS libraries approx. every 5min - elif count % 300 == 0: - log('Running maintainViews() scan', 0) - window('emby_dbScan', value="true") - self.maintainViews() - self.startSync() # Run fast sync otherwise (ever 2 seconds or so) else: self.startSync()