remove some save last sync calls

This commit is contained in:
Shaun 2015-11-24 15:20:01 +11:00
parent 3e1efdf824
commit fc8c41ccf3
2 changed files with 12 additions and 12 deletions

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="plugin.video.emby" <addon id="plugin.video.emby"
name="Emby" name="Emby"
version="1.1.60" version="1.1.61"
provider-name="Emby.media"> provider-name="Emby.media">
<requires> <requires>
<import addon="xbmc.python" version="2.1.0"/> <import addon="xbmc.python" version="2.1.0"/>

View file

@ -109,8 +109,6 @@ class LibrarySync(threading.Thread):
LibrarySync().update_items(changedItems) LibrarySync().update_items(changedItems)
LibrarySync().user_data_update(userChanges) LibrarySync().user_data_update(userChanges)
self.SaveLastSync()
return True return True
else: else:
utils.logMsg("Sync Database", "Too Many For Incremental Sync (" + str(maxItems) + "), changedItems" + str(len(changedItems)) + " removedItems:" + str(len(removedItems)) + " userChanges:" + str(len(userChanges)), 0) utils.logMsg("Sync Database", "Too Many For Incremental Sync (" + str(maxItems) + "), changedItems" + str(len(changedItems)) + " removedItems:" + str(len(removedItems)) + " userChanges:" + str(len(userChanges)), 0)
@ -783,7 +781,7 @@ class LibrarySync(threading.Thread):
finally: finally:
if(pDialog != None): if(pDialog != None):
pDialog.close() pDialog.close()
self.SaveLastSync()
#self.updateLibrary("video") #self.updateLibrary("video")
WINDOW.setProperty("SyncDatabaseRunning", "false") WINDOW.setProperty("SyncDatabaseRunning", "false")
# tell any widgets to refresh because the content has changed # tell any widgets to refresh because the content has changed
@ -898,8 +896,6 @@ class LibrarySync(threading.Thread):
if(pDialog != None): if(pDialog != None):
pDialog.close() pDialog.close()
self.SaveLastSync()
def setUserdata(self, listItems): def setUserdata(self, listItems):
@ -993,8 +989,6 @@ class LibrarySync(threading.Thread):
if(pDialog != None): if(pDialog != None):
pDialog.close() pDialog.close()
self.SaveLastSync()
def remove_items(self, itemsRemoved): def remove_items(self, itemsRemoved):
# websocket client # websocket client
@ -1064,7 +1058,7 @@ class LibrarySync(threading.Thread):
try: try:
self.run_internal() self.run_internal()
except Exception as e: except Exception as e:
xbmcgui.Dialog().ok("Emby for Kodi", "Library sync thread has exited!", "You should restart Kodi now.", "Please report this on the forum.") xbmcgui.Dialog().ok("Emby for Kodi", "Library sync thread has crashed!", "You will need to restart Kodi.", "Please report this on the forum, we will need your log.")
raise raise
def run_internal(self): def run_internal(self):
@ -1140,6 +1134,7 @@ class LibrarySync(threading.Thread):
self.logMsg("Doing_Db_Sync Post Resume: syncDatabase (Finished) " + str(libSync), 0) self.logMsg("Doing_Db_Sync Post Resume: syncDatabase (Finished) " + str(libSync), 0)
doSaveLastSync = False
if len(self.updateItems) > 0 and utils.window('kodiScan') != "true": if len(self.updateItems) > 0 and utils.window('kodiScan') != "true":
# Add or update items # Add or update items
@ -1148,6 +1143,7 @@ class LibrarySync(threading.Thread):
self.updateItems = [] self.updateItems = []
self.IncrementalSync(listItems) self.IncrementalSync(listItems)
self.forceUpdate = True self.forceUpdate = True
doSaveLastSync = True
if len(self.userdataItems) > 0 and utils.window('kodiScan') != "true": if len(self.userdataItems) > 0 and utils.window('kodiScan') != "true":
# Process userdata changes only # Process userdata changes only
@ -1156,6 +1152,7 @@ class LibrarySync(threading.Thread):
self.userdataItems = [] self.userdataItems = []
self.setUserdata(listItems) self.setUserdata(listItems)
self.forceUpdate = True self.forceUpdate = True
doSaveLastSync = True
if len(self.removeItems) > 0 and utils.window('kodiScan') != "true": if len(self.removeItems) > 0 and utils.window('kodiScan') != "true":
# Remove item from Kodi library # Remove item from Kodi library
@ -1164,13 +1161,16 @@ class LibrarySync(threading.Thread):
self.removeItems = [] self.removeItems = []
self.removefromDB(listItems) self.removefromDB(listItems)
self.forceUpdate = True self.forceUpdate = True
doSaveLastSync = True
if doSaveLastSync == True:
self.SaveLastSync()
if self.forceUpdate and not self.updateItems and not self.userdataItems and not self.removeItems: if self.forceUpdate and not self.updateItems and not self.userdataItems and not self.removeItems:
# Force update Kodi library # Force update Kodi library
self.forceUpdate = False self.forceUpdate = False
self.updateLibrary("video") self.updateLibrary("video")
if utils.window("kodiProfile_emby") != kodiProfile: if utils.window("kodiProfile_emby") != kodiProfile:
# Profile change happened, terminate this thread # Profile change happened, terminate this thread
self.logMsg("Kodi profile was: %s and changed to: %s. Terminating Library thread." % (kodiProfile, utils.window("kodiProfile_emby")), 1) self.logMsg("Kodi profile was: %s and changed to: %s. Terminating Library thread." % (kodiProfile, utils.window("kodiProfile_emby")), 1)