save remaining syncmetadata tasks on shutdown
This commit is contained in:
parent
ec81b80d2e
commit
be1c4085f2
2 changed files with 9 additions and 0 deletions
|
@ -873,8 +873,15 @@ def sync_metadata(ids=None):
|
||||||
else:
|
else:
|
||||||
later = []
|
later = []
|
||||||
if ids:
|
if ids:
|
||||||
|
done = set()
|
||||||
for i in Item.query.filter(Item.id.in_(ids)):
|
for i in Item.query.filter(Item.id.in_(ids)):
|
||||||
i.sync_metadata()
|
i.sync_metadata()
|
||||||
|
done.add(i.id)
|
||||||
|
if state.shutdown:
|
||||||
|
later = list((set(later) | set(ids)) - done)
|
||||||
|
if later and state.tasks:
|
||||||
|
state.tasks.queue('syncmetadata', later)
|
||||||
|
later = None
|
||||||
if later:
|
if later:
|
||||||
if state.main and state.tasks:
|
if state.main and state.tasks:
|
||||||
state.main.call_later(delay, lambda: state.tasks.queue('syncmetadata', later))
|
state.main.call_later(delay, lambda: state.tasks.queue('syncmetadata', later))
|
||||||
|
|
|
@ -111,3 +111,5 @@ class Tasks(Thread):
|
||||||
if not state.shutdown:
|
if not state.shutdown:
|
||||||
#logger.debug('queue: %s (%s)', action, data)
|
#logger.debug('queue: %s (%s)', action, data)
|
||||||
self.q.put((priority, (action, data)))
|
self.q.put((priority, (action, data)))
|
||||||
|
else:
|
||||||
|
self._tasks.append((priority, (action, data)))
|
||||||
|
|
Loading…
Reference in a new issue