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,34 +37,43 @@ class LibrarySync():
startupDone = WINDOW.getProperty("startup") == "done" startupDone = WINDOW.getProperty("startup") == "done"
syncInstallRunDone = addon.getSetting("SyncInstallRunDone") == "true" syncInstallRunDone = addon.getSetting("SyncInstallRunDone") == "true"
WINDOW.setProperty("SyncDatabaseRunning", "true")
completed = True if(WINDOW.getProperty("SyncDatabaseShouldStop") == "true"):
utils.logMsg("Sync Database", "Can not start SyncDatabaseShouldStop=True", 0)
# sync movies return True
if(syncInstallRunDone == False): # on first install run do a full sync with model progress dialog
completed = completed and self.TvShowsSync(True, True) try:
completed = completed and self.MoviesSync(True, True) completed = True
completed = completed and self.MusicVideosSync(True, True)
elif(startupDone == False): # on first run after startup do a inc then a full sync # sync movies
self.TvShowsSync(False, False) if(syncInstallRunDone == False): # on first install run do a full sync with model progress dialog
self.MoviesSync(False, False) completed = completed and self.TvShowsSync(True, True)
self.MusicVideosSync(False, False) completed = completed and self.MoviesSync(True, True)
self.TvShowsSync(True, False) completed = completed and self.MusicVideosSync(True, True)
self.MoviesSync(True, False) elif(startupDone == False): # on first run after startup do a inc then a full sync
self.MusicVideosSync(True, False) self.TvShowsSync(False, False)
else: # on scheduled sync do a full sync self.MoviesSync(False, False)
self.TvShowsSync(True, False) self.MusicVideosSync(False, False)
self.MoviesSync(True, False) self.TvShowsSync(True, False)
self.MusicVideosSync(True, False) self.MoviesSync(True, False)
self.MusicVideosSync(True, False)
# set the install done setting else: # on scheduled sync do a full sync
if(syncInstallRunDone == False and completed): self.TvShowsSync(True, False)
addon = xbmcaddon.Addon(id='plugin.video.emby') #force a new instance of the addon self.MoviesSync(True, False)
addon.setSetting("SyncInstallRunDone", "true") self.MusicVideosSync(True, False)
# set prop to show we have run for the first time # set the install done setting
WINDOW.setProperty("startup", "done") if(syncInstallRunDone == False and completed):
addon = xbmcaddon.Addon(id='plugin.video.emby') #force a new instance of the addon
addon.setSetting("SyncInstallRunDone", "true")
# set prop to show we have run for the first time
WINDOW.setProperty("startup", "done")
finally:
WINDOW.setProperty("SyncDatabaseRunning", "false")
return True return True
def MoviesSync(self, fullsync, installFirstRun, itemList = []): def MoviesSync(self, fullsync, installFirstRun, itemList = []):
@ -734,9 +743,14 @@ class LibrarySync():
processMovies = True processMovies = True
processTvShows = 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"): if(WINDOW.getProperty("updatePlayCounts_Running") == "true"):
utils.logMsg("Sync PlayCount", "updatePlayCounts Already Running", 0) utils.logMsg("Sync PlayCount", "updatePlayCounts Already Running", 0)
return False return False
WINDOW.setProperty("updatePlayCounts_Running", "true") WINDOW.setProperty("updatePlayCounts_Running", "true")
try: try:
@ -977,8 +991,12 @@ class LibrarySync():
if(xbmc.Player().isPlaying() or xbmc.abortRequested): if(xbmc.Player().isPlaying() or xbmc.abortRequested):
return True return True
else:
return False 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) xbmcvfs.rmdir(path)
def reset(): 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 # clear video database
connection = KodiSQL() connection = KodiSQL()
cursor = connection.cursor() cursor = connection.cursor()
@ -321,5 +338,6 @@ def reset():
addon.setSetting("SyncFirstCountsRunDone", "false") addon.setSetting("SyncFirstCountsRunDone", "false")
dialog = xbmcgui.Dialog() 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")