Fixed potential loop in inc sync

This commit is contained in:
angelblue05 2017-11-25 17:33:44 -06:00
parent c34d26ebed
commit 6644504005

View file

@ -46,6 +46,7 @@ class LibrarySync(threading.Thread):
userdataItems = [] userdataItems = []
removeItems = [] removeItems = []
forceLibraryUpdate = False forceLibraryUpdate = False
incremental_count = 0
refresh_views = False refresh_views = False
@ -521,6 +522,7 @@ class LibrarySync(threading.Thread):
def incrementalSync(self): def incrementalSync(self):
self.incremental_count += 1
update_embydb = False update_embydb = False
pDialog = None pDialog = None
@ -532,7 +534,7 @@ class LibrarySync(threading.Thread):
# do a lib update if any items in list # do a lib update if any items in list
totalUpdates = len(self.addedItems) + len(self.updateItems) + len(self.userdataItems) + len(self.removeItems) totalUpdates = len(self.addedItems) + len(self.updateItems) + len(self.userdataItems) + len(self.removeItems)
if totalUpdates > 0: if totalUpdates > 0 and window('emby_kodiScan') != "true":
with database.DatabaseConn('emby') as cursor_emby: with database.DatabaseConn('emby') as cursor_emby:
with database.DatabaseConn('video') as cursor_video: with database.DatabaseConn('video') as cursor_video:
@ -553,7 +555,7 @@ class LibrarySync(threading.Thread):
} }
for process_type in ['added', 'update', 'userdata', 'remove']: for process_type in ['added', 'update', 'userdata', 'remove']:
if process[process_type] and window('emby_kodiScan') != "true": if process[process_type]:
listItems = list(process[process_type]) listItems = list(process[process_type])
del process[process_type][:] # Reset class list del process[process_type][:] # Reset class list
@ -600,13 +602,13 @@ class LibrarySync(threading.Thread):
self.forceLibraryUpdate = False self.forceLibraryUpdate = False
log.info("Updating video library.") log.info("Updating video library.")
self.incremental_count = 0
window('emby_kodiScan', value="true") window('emby_kodiScan', value="true")
xbmc.executebuiltin('UpdateLibrary(video)') xbmc.executebuiltin('UpdateLibrary(video)')
if pDialog: if pDialog:
pDialog.close() pDialog.close()
def compareDBVersion(self, current, minimum): def compareDBVersion(self, current, minimum):
# It returns True is database is up to date. False otherwise. # It returns True is database is up to date. False otherwise.
log.info("current: %s minimum: %s" % (current, minimum)) log.info("current: %s minimum: %s" % (current, minimum))
@ -738,6 +740,10 @@ class LibrarySync(threading.Thread):
startupComplete = True startupComplete = True
# Process updates # Process updates
if self.incremental_count > 5:
self.incremental_count = 0
window('emby_kodiScan', clear=True)
if window('emby_dbScan') != "true" and window('emby_shouldStop') != "true": if window('emby_dbScan') != "true" and window('emby_shouldStop') != "true":
self.incrementalSync() self.incrementalSync()