Fix permanent missing library items if PMS failed to send a single response

This commit is contained in:
croneter 2018-12-10 20:00:48 +01:00
parent 97d829779f
commit 1a46664051

View file

@ -273,11 +273,16 @@ class FullSync(common.libsync_mixin):
element['element_type'] = kind[1] element['element_type'] = kind[1]
element['context'] = kind[2] element['context'] = kind[2]
element['get_children'] = kind[3] element['get_children'] = kind[3]
element['iterator'] = PF.SectionItems(section['section_id'], try:
plex_type=kind[0], element['iterator'] = PF.SectionItems(section['section_id'],
updated_at=updated_at, plex_type=kind[0],
last_viewed_at=last_viewed_at) updated_at=updated_at,
queue.put(element) last_viewed_at=last_viewed_at)
except RuntimeError:
LOG.warn('Sync at least partially unsuccessful')
self.successful = False
else:
queue.put(element)
finally: finally:
queue.put(None) queue.put(None)
@ -383,7 +388,7 @@ class FullSync(common.libsync_mixin):
# Get latest Plex libraries and build playlist and video node files # Get latest Plex libraries and build playlist and video node files
if not sections.sync_from_pms(): if not sections.sync_from_pms():
return return
successful = False self.successful = True
try: try:
self.queue = backgroundthread.Queue.Queue() self.queue = backgroundthread.Queue.Queue()
if self.show_dialog: if self.show_dialog:
@ -394,22 +399,24 @@ class FullSync(common.libsync_mixin):
LOG.info('Running full_library_sync with repair=%s', LOG.info('Running full_library_sync with repair=%s',
self.repair) self.repair)
if not self.full_library_sync(): if not self.full_library_sync():
self.successful = False
return return
if self.isCanceled(): if self.isCanceled():
self.successful = False
return return
if PLAYLIST_SYNC_ENABLED and not playlists.full_sync(): if PLAYLIST_SYNC_ENABLED and not playlists.full_sync():
self.successful = False
return return
successful = True
finally: finally:
common.update_kodi_library(video=True, music=True) common.update_kodi_library(video=True, music=True)
if self.dialog: if self.dialog:
self.dialog.close() self.dialog.close()
if self.threader: if self.threader:
self.threader.shutdown() self.threader.shutdown()
if successful: if self.successful:
utils.settings('lastfullsync', value=str(int(self.current_sync))) utils.settings('lastfullsync', value=str(int(self.current_sync)))
if self.callback: if self.callback:
self.callback(successful) self.callback(self.successful)
LOG.info('Done full_sync') LOG.info('Done full_sync')