From 0fe2de1705fd452d878cfb34c8cd596276e7ac63 Mon Sep 17 00:00:00 2001 From: croneter Date: Sun, 25 Nov 2018 21:07:25 +0100 Subject: [PATCH] Fix resetting of databases crashing --- default.py | 2 +- resources/lib/service_entry.py | 2 ++ resources/lib/utils.py | 7 ++++--- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/default.py b/default.py index ac6ae083..b5dffe69 100644 --- a/default.py +++ b/default.py @@ -89,7 +89,7 @@ class Main(): entrypoint.create_new_pms() elif mode == 'reset': - utils.reset() + utils.plex_command('RESET-PKC') elif mode == 'togglePlexTV': entrypoint.toggle_plex_tv_sign_in() diff --git a/resources/lib/service_entry.py b/resources/lib/service_entry.py index dded2801..76687ba3 100644 --- a/resources/lib/service_entry.py +++ b/resources/lib/service_entry.py @@ -391,6 +391,8 @@ class Service(): app.SYNC.run_lib_scan = 'fanart' elif plex_command == 'textures-scan': app.SYNC.run_lib_scan = 'textures' + elif plex_command == 'RESET-PKC': + utils.reset() continue if app.APP.suspend: diff --git a/resources/lib/utils.py b/resources/lib/utils.py index ad8d7a0a..0337d140 100644 --- a/resources/lib/utils.py +++ b/resources/lib/utils.py @@ -486,16 +486,17 @@ def reset(ask_user=True): # Are you sure you want to reset your local Kodi database? if ask_user and not yesno_dialog(lang(29999), lang(39600)): return - + from . import app # first stop any db sync - plex_command('STOP_SYNC', 'True') + app.APP.suspend_threads = True count = 10 - while window('plex_dbScan') == "true": + while app.SYNC.db_scan: LOG.debug("Sync is running, will retry: %s...", count) count -= 1 if count == 0: # Could not stop the database from running. Please try again later. messageDialog(lang(29999), lang(39601)) + app.APP.suspend_threads = False return xbmc.sleep(1000)