From 22b62133eb5c538964a198bdfe072b4280c856e8 Mon Sep 17 00:00:00 2001 From: angelblue05 Date: Thu, 22 Oct 2015 21:55:27 -0500 Subject: [PATCH] Kodi database scan Prevent writing to database when the kodi database scan is running. --- resources/lib/KodiMonitor.py | 8 ++++++++ resources/lib/LibrarySync.py | 6 +++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/resources/lib/KodiMonitor.py b/resources/lib/KodiMonitor.py index d9b22e8e..a2216eb0 100644 --- a/resources/lib/KodiMonitor.py +++ b/resources/lib/KodiMonitor.py @@ -27,6 +27,14 @@ class Kodi_Monitor( xbmc.Monitor ): className = self.__class__.__name__ utils.logMsg("%s %s" % ("EMBY", className), msg, int(lvl)) + + def onScanStarted(self, library): + utils.window('kodiScan', value="true") + self.logMsg("Kodi library scan running.", 2) + + def onScanFinished(self, library): + utils.window('kodiScan', clear=True) + self.logMsg("Kodi library scan finished.", 2) #this library monitor is used to detect a watchedstate change by the user through the library #as well as detect when a library item has been deleted to pass the delete to the Emby server diff --git a/resources/lib/LibrarySync.py b/resources/lib/LibrarySync.py index 61155ee4..c8ee381d 100644 --- a/resources/lib/LibrarySync.py +++ b/resources/lib/LibrarySync.py @@ -1108,21 +1108,21 @@ class LibrarySync(threading.Thread): - if len(self.updateItems) > 0: + if len(self.updateItems) > 0 and utils.window('kodiScan') != "true": # Add or update items self.logMsg("Processing items: %s" % (str(self.updateItems)), 1) listItems = self.updateItems self.updateItems = [] self.IncrementalSync(listItems) - if len(self.userdataItems) > 0: + if len(self.userdataItems) > 0 and utils.window('kodiScan') != "true": # Process userdata changes only self.logMsg("Processing items: %s" % (str(self.userdataItems)), 1) listItems = self.userdataItems self.userdataItems = [] self.setUserdata(listItems) - if len(self.removeItems) > 0: + if len(self.removeItems) > 0 and utils.window('kodiScan') != "true": # Remove item from Kodi library self.logMsg("Removing items: %s" % self.removeItems, 1) listItems = self.removeItems