Sync running check added to Reset Action

This commit is contained in:
shaun 2015-04-03 19:39:16 +11:00
parent f90bda68cf
commit 07ff102a40
2 changed files with 66 additions and 30 deletions

View file

@ -37,7 +37,13 @@ class LibrarySync():
startupDone = WINDOW.getProperty("startup") == "done"
syncInstallRunDone = addon.getSetting("SyncInstallRunDone") == "true"
WINDOW.setProperty("SyncDatabaseRunning", "true")
if(WINDOW.getProperty("SyncDatabaseShouldStop") == "true"):
utils.logMsg("Sync Database", "Can not start SyncDatabaseShouldStop=True", 0)
return True
try:
completed = True
# sync movies
@ -65,6 +71,9 @@ class LibrarySync():
# set prop to show we have run for the first time
WINDOW.setProperty("startup", "done")
finally:
WINDOW.setProperty("SyncDatabaseRunning", "false")
return True
def MoviesSync(self, fullsync, installFirstRun, itemList = []):
@ -734,9 +743,14 @@ class LibrarySync():
processMovies = True
processTvShows = True
if(WINDOW.getProperty("SyncDatabaseShouldStop") == "true"):
utils.logMsg("Sync PlayCount", "Can not start SyncDatabaseShouldStop=True", 0)
return True
if(WINDOW.getProperty("updatePlayCounts_Running") == "true"):
utils.logMsg("Sync PlayCount", "updatePlayCounts Already Running", 0)
return False
WINDOW.setProperty("updatePlayCounts_Running", "true")
try:
@ -977,7 +991,11 @@ class LibrarySync():
if(xbmc.Player().isPlaying() or xbmc.abortRequested):
return True
else:
WINDOW = xbmcgui.Window( 10000 )
if(WINDOW.getProperty("SyncDatabaseShouldStop") == "true"):
return True
return False

View file

@ -150,6 +150,23 @@ def removeDirectory(path):
xbmcvfs.rmdir(path)
def reset():
return_value = xbmcgui.Dialog().yesno("Warning", "Are you sure you want to reset your local database?")
if return_value == 0:
return
# first stop any db sync
WINDOW = xbmcgui.Window( 10000 )
WINDOW.setProperty("SyncDatabaseShouldStop", "true")
count = 0
while(WINDOW.getProperty("SyncDatabaseRunning") == "true"):
count += 1
if(count > 10):
dialog.ok('Warning', 'Could not stop DB sync, you should try again.')
return
xbmc.sleep(1000)
# clear video database
connection = KodiSQL()
cursor = connection.cursor()
@ -321,5 +338,6 @@ def reset():
addon.setSetting("SyncFirstCountsRunDone", "false")
dialog = xbmcgui.Dialog()
dialog.ok('Emby Reset', 'Reset of Emby has completed, please restart.')
dialog.ok('Emby Reset', 'Reset of Emby has completed, you need to restart.')
xbmc.executebuiltin("RestartApp")