From 080e9184ccd3beac5e89c6e68934a3f5acf85b3b Mon Sep 17 00:00:00 2001 From: Croneter Date: Thu, 5 Jul 2018 16:38:06 +0200 Subject: [PATCH] Fix and optimize startup of playlist sync --- resources/lib/librarysync.py | 11 +++++------ resources/lib/playlists.py | 6 ++++++ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/resources/lib/librarysync.py b/resources/lib/librarysync.py index 73bb6cf2..41fc10e0 100644 --- a/resources/lib/librarysync.py +++ b/resources/lib/librarysync.py @@ -262,9 +262,10 @@ class LibrarySync(Thread): # This will NOT update playstates and userratings! LOG.info('Running fullsync for CHANGED PMS items with repair=%s', repair) - if self._full_sync() is False: + if not self._full_sync(): + return False + if not playlists.full_sync(): return False - playlists.full_sync() return True def _full_sync(self): @@ -1561,10 +1562,9 @@ class LibrarySync(Thread): initial_sync_done = True kodi_db_version_checked = True last_sync = utils.unix_timestamp() + playlist_monitor = playlists.kodi_playlist_monitor() self.sync_fanart() self.fanartthread.start() - if state.SYNC_PLAYLISTS and playlists.full_sync(): - playlist_monitor = playlists.kodi_playlist_monitor() else: LOG.error('Initial start-up full sync unsuccessful') xbmc.executebuiltin('InhibitIdleShutdown(false)') @@ -1614,11 +1614,10 @@ class LibrarySync(Thread): initial_sync_done = True last_sync = utils.unix_timestamp() LOG.info('Done initial sync on Kodi startup') + playlist_monitor = playlists.kodi_playlist_monitor() artwork.Artwork().cache_major_artwork() self.sync_fanart() self.fanartthread.start() - if state.SYNC_PLAYLISTS and playlists.full_sync(): - playlist_monitor = playlists.kodi_playlist_monitor() else: LOG.info('Startup sync has not yet been successful') utils.window('plex_dbScan', clear=True) diff --git a/resources/lib/playlists.py b/resources/lib/playlists.py index c8dcb155..58f8fd9f 100644 --- a/resources/lib/playlists.py +++ b/resources/lib/playlists.py @@ -329,6 +329,9 @@ def full_sync(): Full sync of playlists between Kodi and Plex. Returns True is successful, False otherwise """ + if not state.SYNC_PLAYLISTS: + LOG.debug('Not syncing playlists') + return True LOG.info('Starting playlist full sync') with state.LOCK_PLAYLISTS: return _full_sync() @@ -467,6 +470,9 @@ class PlaylistEventhandler(events.FileSystemEventHandler): :type event: :class:`FileSystemEvent` """ + if not state.SYNC_PLAYLISTS: + # Sync is deactivated + return if event.is_directory: # todo: take care of folder renames return