diff --git a/resources/lib/sync.py b/resources/lib/sync.py index 37ab378f..6c7755e0 100644 --- a/resources/lib/sync.py +++ b/resources/lib/sync.py @@ -213,14 +213,8 @@ class Sync(backgroundthread.KillableThread): else: utils.reset(ask_user=False) return - # Ensure that Plex DB is set-up - plex_db.initialize() - # Hack to speed up look-ups for actors (giant table!) - utils.create_kodi_db_indicees() - kodi_db.setup_kodi_default_entries() - with kodi_db.KodiVideoDB() as kodidb: - # Setup the paths for addon-paths (even when using direct paths) - kodidb.setup_path_table() + + utils.init_dbs() while not self.isCanceled(): # In the event the server goes offline diff --git a/resources/lib/utils.py b/resources/lib/utils.py index 681d81d7..ccb51b83 100644 --- a/resources/lib/utils.py +++ b/resources/lib/utils.py @@ -482,6 +482,23 @@ def wipe_database(): settings('SyncInstallRunDone', value="false") settings('lastfullsync', value="0") LOG.info('Wiping done') + init_dbs() + + +def init_dbs(): + """ + Call e.g. on startup to ensure that Plex and Kodi DBs look like they should + """ + from . import kodi_db, plex_db + # Ensure that Plex DB is set-up + plex_db.initialize() + # Hack to speed up look-ups for actors (giant table!) + create_kodi_db_indicees() + kodi_db.setup_kodi_default_entries() + with kodi_db.KodiVideoDB() as kodidb: + # Setup the paths for addon-paths (even when using direct paths) + kodidb.setup_path_table() + LOG.info('Init DBs done') def reset(ask_user=True):