Fix resetting of databases crashing

This commit is contained in:
croneter 2018-11-25 21:07:25 +01:00
parent ded8a59dd7
commit 0fe2de1705
3 changed files with 7 additions and 4 deletions

View file

@ -89,7 +89,7 @@ class Main():
entrypoint.create_new_pms() entrypoint.create_new_pms()
elif mode == 'reset': elif mode == 'reset':
utils.reset() utils.plex_command('RESET-PKC')
elif mode == 'togglePlexTV': elif mode == 'togglePlexTV':
entrypoint.toggle_plex_tv_sign_in() entrypoint.toggle_plex_tv_sign_in()

View file

@ -391,6 +391,8 @@ class Service():
app.SYNC.run_lib_scan = 'fanart' app.SYNC.run_lib_scan = 'fanart'
elif plex_command == 'textures-scan': elif plex_command == 'textures-scan':
app.SYNC.run_lib_scan = 'textures' app.SYNC.run_lib_scan = 'textures'
elif plex_command == 'RESET-PKC':
utils.reset()
continue continue
if app.APP.suspend: if app.APP.suspend:

View file

@ -486,16 +486,17 @@ def reset(ask_user=True):
# Are you sure you want to reset your local Kodi database? # Are you sure you want to reset your local Kodi database?
if ask_user and not yesno_dialog(lang(29999), lang(39600)): if ask_user and not yesno_dialog(lang(29999), lang(39600)):
return return
from . import app
# first stop any db sync # first stop any db sync
plex_command('STOP_SYNC', 'True') app.APP.suspend_threads = True
count = 10 count = 10
while window('plex_dbScan') == "true": while app.SYNC.db_scan:
LOG.debug("Sync is running, will retry: %s...", count) LOG.debug("Sync is running, will retry: %s...", count)
count -= 1 count -= 1
if count == 0: if count == 0:
# Could not stop the database from running. Please try again later. # Could not stop the database from running. Please try again later.
messageDialog(lang(29999), lang(39601)) messageDialog(lang(29999), lang(39601))
app.APP.suspend_threads = False
return return
xbmc.sleep(1000) xbmc.sleep(1000)