Fix items getting deleted on subsequent sync

This commit is contained in:
croneter 2018-12-01 18:50:52 +01:00
parent 056463da55
commit 7fce226d47

View file

@ -105,10 +105,11 @@ class FullSync(common.libsync_mixin):
section['section_id'], section['section_id'],
section['plex_type']) section['plex_type'])
self.queue.put(queue_info) self.queue.put(queue_info)
for xml_item in iterator: with PlexDB() as self.plexdb:
if self.isCanceled(): for xml_item in iterator:
return False if self.isCanceled():
self.process_item(xml_item) return False
self.process_item(xml_item)
except RuntimeError: except RuntimeError:
LOG.error('Could not entirely process section %s', section) LOG.error('Could not entirely process section %s', section)
return False return False
@ -128,8 +129,12 @@ class FullSync(common.libsync_mixin):
section['section_id'], section['section_id'],
section['plex_type']) section['plex_type'])
self.queue.put(queue_info) self.queue.put(queue_info)
if section['plex_type'] != v.PLEX_TYPE_ARTIST: with PlexDB() as self.plexdb:
self.process_playstate(iterator) if section['plex_type'] != v.PLEX_TYPE_ARTIST:
self.process_playstate(iterator)
# Delete movies that are not on Plex anymore
self.process_delete()
# Wait again till the processing thread is done
self.queue.join() self.queue.join()
except RuntimeError: except RuntimeError:
LOG.error('Could not process playstate for section %s', section) LOG.error('Could not process playstate for section %s', section)
@ -183,22 +188,19 @@ class FullSync(common.libsync_mixin):
kinds, kinds,
iterator_queue) iterator_queue)
backgroundthread.BGThreader.addTask(task) backgroundthread.BGThreader.addTask(task)
with PlexDB() as self.plexdb: while True:
while True: section = iterator_queue.get()
section = iterator_queue.get() if section is None:
if section is None: break
break # Setup our variables
# Setup our variables self.plex_type = section['plex_type']
self.plex_type = section['plex_type'] self.section_type = section['section_type']
self.section_type = section['section_type'] self.context = section['context']
self.context = section['context'] self.get_children = section['get_children']
self.get_children = section['get_children'] # Now do the heavy lifting
# Now do the heavy lifting if self.isCanceled() or not self.process_section(section):
if self.isCanceled() or not self.process_section(section): return False
return False iterator_queue.task_done()
# Delete movies that are not on Plex anymore
self.process_delete()
iterator_queue.task_done()
return True return True
@utils.log_time @utils.log_time