Cancels syncs if lib sync thread gets suspended

- Partially solves #333
This commit is contained in:
croneter 2017-08-19 16:26:51 +02:00
parent 3daf82ef3d
commit c0bef37dd5

View file

@ -296,7 +296,9 @@ class LibrarySync(Thread):
# Do the processing # Do the processing
for itemtype in process: for itemtype in process:
if self.thread_stopped() or not process[itemtype](): if (self.thread_stopped() or
self.thread_suspended() or
not process[itemtype]()):
xbmc.executebuiltin('InhibitIdleShutdown(false)') xbmc.executebuiltin('InhibitIdleShutdown(false)')
setScreensaver(value=screensaver) setScreensaver(value=screensaver)
return False return False
@ -795,7 +797,7 @@ class LibrarySync(Thread):
for view in views: for view in views:
if self.installSyncDone is not True: if self.installSyncDone is not True:
state.PATH_VERIFIED = False state.PATH_VERIFIED = False
if self.thread_stopped(): if self.thread_stopped() or self.thread_suspended():
return False return False
# Get items per view # Get items per view
viewId = view['id'] viewId = view['id']
@ -813,10 +815,9 @@ class LibrarySync(Thread):
viewName, viewName,
viewId) viewId)
self.GetAndProcessXMLs(itemType) self.GetAndProcessXMLs(itemType)
log.info("Processed view")
# Update viewstate for EVERY item # Update viewstate for EVERY item
for view in views: for view in views:
if self.thread_stopped(): if self.thread_stopped() or self.thread_suspended():
return False return False
self.PlexUpdateWatched(view['id'], itemType) self.PlexUpdateWatched(view['id'], itemType)
@ -890,7 +891,7 @@ class LibrarySync(Thread):
for view in views: for view in views:
if self.installSyncDone is not True: if self.installSyncDone is not True:
state.PATH_VERIFIED = False state.PATH_VERIFIED = False
if self.thread_stopped(): if self.thread_stopped() or self.thread_suspended():
return False return False
# Get items per view # Get items per view
viewId = view['id'] viewId = view['id']
@ -919,7 +920,7 @@ class LibrarySync(Thread):
# PROCESS TV Seasons ##### # PROCESS TV Seasons #####
# Cycle through tv shows # Cycle through tv shows
for tvShowId in allPlexTvShowsId: for tvShowId in allPlexTvShowsId:
if self.thread_stopped(): if self.thread_stopped() or self.thread_suspended():
return False return False
# Grab all seasons to tvshow from PMS # Grab all seasons to tvshow from PMS
seasons = GetAllPlexChildren(tvShowId) seasons = GetAllPlexChildren(tvShowId)
@ -944,7 +945,7 @@ class LibrarySync(Thread):
# PROCESS TV Episodes ##### # PROCESS TV Episodes #####
# Cycle through tv shows # Cycle through tv shows
for view in views: for view in views:
if self.thread_stopped(): if self.thread_stopped() or self.thread_suspended():
return False return False
# Grab all episodes to tvshow from PMS # Grab all episodes to tvshow from PMS
episodes = GetAllPlexLeaves(view['id']) episodes = GetAllPlexLeaves(view['id'])
@ -979,7 +980,7 @@ class LibrarySync(Thread):
# Update viewstate: # Update viewstate:
for view in views: for view in views:
if self.thread_stopped(): if self.thread_stopped() or self.thread_suspended():
return False return False
self.PlexUpdateWatched(view['id'], itemType) self.PlexUpdateWatched(view['id'], itemType)
@ -1016,7 +1017,7 @@ class LibrarySync(Thread):
for kind in (v.PLEX_TYPE_ARTIST, for kind in (v.PLEX_TYPE_ARTIST,
v.PLEX_TYPE_ALBUM, v.PLEX_TYPE_ALBUM,
v.PLEX_TYPE_SONG): v.PLEX_TYPE_SONG):
if self.thread_stopped(): if self.thread_stopped() or self.thread_suspended():
return False return False
log.debug("Start processing music %s" % kind) log.debug("Start processing music %s" % kind)
self.allKodiElementsId = {} self.allKodiElementsId = {}
@ -1033,7 +1034,7 @@ class LibrarySync(Thread):
# Update viewstate for EVERY item # Update viewstate for EVERY item
for view in views: for view in views:
if self.thread_stopped(): if self.thread_stopped() or self.thread_suspended():
return False return False
self.PlexUpdateWatched(view['id'], itemType) self.PlexUpdateWatched(view['id'], itemType)
@ -1060,7 +1061,7 @@ class LibrarySync(Thread):
for view in views: for view in views:
if self.installSyncDone is not True: if self.installSyncDone is not True:
state.PATH_VERIFIED = False state.PATH_VERIFIED = False
if self.thread_stopped(): if self.thread_stopped() or self.thread_suspended():
return False return False
# Get items per view # Get items per view
itemsXML = GetPlexSectionResults(view['id'], args=urlArgs) itemsXML = GetPlexSectionResults(view['id'], args=urlArgs)
@ -1135,7 +1136,7 @@ class LibrarySync(Thread):
now = getUnixTimestamp() now = getUnixTimestamp()
deleteListe = [] deleteListe = []
for i, item in enumerate(self.itemsToProcess): for i, item in enumerate(self.itemsToProcess):
if self.thread_stopped(): if self.thread_stopped() or self.thread_suspended():
# Chances are that Kodi gets shut down # Chances are that Kodi gets shut down
break break
if item['state'] == 9: if item['state'] == 9: