Don't spawn a separate full sync thread

This commit is contained in:
croneter 2018-11-05 13:52:31 +01:00
parent 0d5f59ab84
commit 0536a7c151
2 changed files with 14 additions and 16 deletions

View file

@ -20,7 +20,7 @@ else:
LOG = getLogger('PLEX.sync.full_sync') LOG = getLogger('PLEX.sync.full_sync')
class FullSync(backgroundthread.KillableThread, common.libsync_mixin): class FullSync(common.libsync_mixin):
def __init__(self, repair, callback, show_dialog): def __init__(self, repair, callback, show_dialog):
""" """
repair=True: force sync EVERY item repair=True: force sync EVERY item
@ -213,5 +213,5 @@ class FullSync(backgroundthread.KillableThread, common.libsync_mixin):
def start(show_dialog, repair=False, callback=None): def start(show_dialog, repair=False, callback=None):
""" """
""" """
# backgroundthread.BGThreader.addTask(FullSync().setup(repair, callback)) # FullSync(repair, callback, show_dialog).start()
FullSync(repair, callback, show_dialog).start() FullSync(repair, callback, show_dialog).run()

View file

@ -40,7 +40,7 @@ class Sync(backgroundthread.KillableThread):
# Show sync dialog even if user deactivated? # Show sync dialog even if user deactivated?
self.force_dialog = False self.force_dialog = False
# Lock used to wait on a full sync, e.g. on initial sync # Lock used to wait on a full sync, e.g. on initial sync
self.lock = backgroundthread.threading.Lock() # self.lock = backgroundthread.threading.Lock()
super(Sync, self).__init__() super(Sync, self).__init__()
def isCanceled(self): def isCanceled(self):
@ -126,21 +126,19 @@ class Sync(backgroundthread.KillableThread):
self.sync_successful = successful self.sync_successful = successful
self.last_full_sync = utils.unix_timestamp() self.last_full_sync = utils.unix_timestamp()
set_library_scan_toggle(boolean=False) set_library_scan_toggle(boolean=False)
try: # try:
self.lock.release() # self.lock.release()
except backgroundthread.threading.ThreadError: # except backgroundthread.threading.ThreadError:
pass # pass
def start_library_sync(self, show_dialog=None, repair=False, block=False): def start_library_sync(self, show_dialog=None, repair=False, block=False):
show_dialog = show_dialog if show_dialog is not None else state.SYNC_DIALOG show_dialog = show_dialog if show_dialog is not None else state.SYNC_DIALOG
if block:
self.lock.acquire()
library_sync.start(show_dialog, repair, self.on_library_scan_finished) library_sync.start(show_dialog, repair, self.on_library_scan_finished)
# if block:
# self.lock.acquire()
# Will block until scan is finished # Will block until scan is finished
self.lock.acquire() # self.lock.acquire()
self.lock.release() # self.lock.release()
else:
library_sync.start(show_dialog, repair, self.on_library_scan_finished)
def start_fanart_download(self, refresh): def start_fanart_download(self, refresh):
if not utils.settings('FanartTV') == 'true': if not utils.settings('FanartTV') == 'true':