Small improvements lib sync

This commit is contained in:
tomkat83 2016-02-11 10:56:01 +01:00
parent 8217932985
commit 28517b509a

View file

@ -252,7 +252,7 @@ class LibrarySync(threading.Thread):
# Fast sync failed or server plugin is not found # Fast sync failed or server plugin is not found
self.logMsg("Something went wrong, starting full sync", 0) self.logMsg("Something went wrong, starting full sync", 0)
completed = self.fullSync(manualrun=True) completed = self.fullSync(manualrun=True)
utils.window('emby_dbScan', value="false") utils.window('emby_dbScan', clear=True)
return completed return completed
def fastSync(self): def fastSync(self):
@ -1153,13 +1153,14 @@ class LibrarySync(threading.Thread):
self.logMsg("---===### Starting LibrarySync ###===---", 0) self.logMsg("---===### Starting LibrarySync ###===---", 0)
while not self.threadStopped(): while not self.threadStopped():
# In the event the server goes offline # In the event the server goes offline, or an item is playing
while self.threadSuspended(): while self.threadSuspended():
# Set in service.py # Set in service.py
if self.threadStopped(): if self.threadStopped():
# Abort was requested while waiting. We should exit # Abort was requested while waiting. We should exit
self.logMsg("###===--- LibrarySync Stopped ---===###", 0)
return return
xbmc.sleep(3000) xbmc.sleep(1000)
if (utils.window('emby_dbCheck') != "true" and if (utils.window('emby_dbCheck') != "true" and
self.installSyncDone): self.installSyncDone):
@ -1227,37 +1228,37 @@ class LibrarySync(threading.Thread):
utils.settings( utils.settings(
"dbCreatedWithVersion", self.clientInfo.getVersion()) "dbCreatedWithVersion", self.clientInfo.getVersion())
self.installSyncDone = True self.installSyncDone = True
utils.window('emby_dbScan', value="false") utils.window('emby_dbScan', clear=True)
# Currently no db scan, so we can start a new scan # Currently no db scan, so we can start a new scan
elif utils.window('emby_dbScan') != "true": elif utils.window('emby_dbScan') != "true":
# Full scan was requested from somewhere else, e.g. userclient # Full scan was requested from somewhere else, e.g. userclient
if utils.window('plex_runLibScan') == "true": if utils.window('plex_runLibScan') == "true":
self.logMsg('Full library scan requested, starting', 1) self.logMsg('Full library scan requested, starting', 0)
utils.window('emby_dbScan', value="true") utils.window('emby_dbScan', value="true")
utils.window('plex_runLibScan', value='false') utils.window('plex_runLibScan', clear=True)
self.fullSync(manualrun=True) self.fullSync(manualrun=True)
utils.window('emby_dbScan', value="false") utils.window('emby_dbScan', clear=True)
count = 0 count = 0
else: else:
# Run full lib scan approx every 10min # Run full lib scan approx every 30min
if count % 600 == 0: if count >= 1800:
utils.window('emby_dbScan', value="true")
self.logMsg('Running maintainViews() scan', 1)
self.fullSync(manualrun=True)
count = 0 count = 0
utils.window('emby_dbScan', value="false") utils.window('emby_dbScan', value="true")
# Update views / PMS libraries approx. every 5 self.logMsg('Running automatic full lib scan', 0)
elif count % 120 == 0: self.fullSync(manualrun=True)
self.logMsg('Running maintainViews() scan', 1) utils.window('emby_dbScan', clear=True)
# Update views / PMS libraries approx. every 5min
elif count % 300 == 0:
self.logMsg('Running maintainViews() scan', 0)
utils.window('emby_dbScan', value="true") utils.window('emby_dbScan', value="true")
self.maintainViews() self.maintainViews()
self.startSync() self.startSync()
# Run fast sync otherwise (ever second or so) # Run fast sync otherwise (ever 2 seconds or so)
else: else:
self.startSync() self.startSync()
xbmc.sleep(1000) xbmc.sleep(2000)
count += 1 count += 1
self.logMsg("###===--- LibrarySync Stopped ---===###", 0) self.logMsg("###===--- LibrarySync Stopped ---===###", 0)