diff --git a/resources/lib/initialsetup.py b/resources/lib/initialsetup.py index c9a87b8b..45cb4683 100644 --- a/resources/lib/initialsetup.py +++ b/resources/lib/initialsetup.py @@ -693,14 +693,12 @@ class InitialSetup(object): # Open Settings page now? You will need to restart! goto_settings = utils.yesno_dialog(utils.lang(29999), utils.lang(39017)) + # New installation - make sure we start with a clean slate + utils.wipe_database(reboot=False) if goto_settings: + LOG.info('User chose to go to the PKC settings - suspending PKC') app.APP.stop_pkc = True executebuiltin( 'Addon.OpenSettings(plugin.video.plexkodiconnect)') - # New installation - make sure we start with a clean slate - # Will trigger a reboot, usually - utils.wipe_database() - # Reload relevant settings if that is not the case - app.CONN.load() - app.ACCOUNT.load() - app.SYNC.load() + return + utils.reboot_kodi() diff --git a/resources/lib/utils.py b/resources/lib/utils.py index 9d57917d..be8aadcc 100644 --- a/resources/lib/utils.py +++ b/resources/lib/utils.py @@ -539,7 +539,7 @@ def create_kodi_db_indicees(): conn.close() -def wipe_database(): +def wipe_database(reboot=True): """ Deletes all Plex playlists as well as video nodes, then clears Kodi as well as Plex databases completely. @@ -585,10 +585,11 @@ def wipe_database(): settings('sections_asked_for_machine_identifier', value='') init_dbs() LOG.info('Wiping done') - if settings('kodi_db_has_been_wiped_clean') != 'true': + no_reboot = settings('kodi_db_has_been_wiped_clean') == 'true' or not reboot + settings('kodi_db_has_been_wiped_clean', value='true') + if not no_reboot: # Root cause is sqlite WAL mode - Kodi might still have DB access open LOG.warn('Need to restart Kodi before filling Kodi DB again') - settings('kodi_db_has_been_wiped_clean', value='true') reboot_kodi()