queue previews after sync
This commit is contained in:
parent
5b6ef3d669
commit
ab7863807b
3 changed files with 19 additions and 3 deletions
|
@ -377,6 +377,10 @@ def sync_db():
|
|||
from sqlalchemy.orm import load_only
|
||||
import item.models
|
||||
first = True
|
||||
missing_previews = []
|
||||
state.sync_db = True
|
||||
|
||||
#FIXME: why is this loop needed
|
||||
with db.session():
|
||||
sort_ids = {i.item_id for i in item.models.Sort.query.options(load_only('item_id'))}
|
||||
if sort_ids:
|
||||
|
@ -387,9 +391,11 @@ def sync_db():
|
|||
if first:
|
||||
first = False
|
||||
logger.debug('sync items')
|
||||
i.update(commit=False)
|
||||
if i.info.get('mediastate') == 'unavailable' and state.tasks:
|
||||
state.tasks.queue('getpreview', i.id)
|
||||
#why?
|
||||
#i.update(commit=False)
|
||||
i.update_sort(commit=False)
|
||||
if i.info.get('mediastate') == 'unavailable':
|
||||
missing_previews.append(i.id)
|
||||
commit = True
|
||||
#logger.debug('sync:%s', i)
|
||||
t0 = maybe_commit(t0)
|
||||
|
@ -397,6 +403,7 @@ def sync_db():
|
|||
break
|
||||
if commit:
|
||||
state.db.session.commit()
|
||||
|
||||
if not first:
|
||||
logger.debug('synced items')
|
||||
if not state.shutdown:
|
||||
|
@ -408,6 +415,12 @@ def sync_db():
|
|||
item.models.Sort.query.filter_by(item_id=None).delete()
|
||||
item.models.Find.query.filter_by(item_id=None).delete()
|
||||
|
||||
if missing_previews and state.tasks:
|
||||
logger.debug('queueing download of %s missing previews', len(missing_previews))
|
||||
for id in missing_previews:
|
||||
state.tasks.queue('getpreview', id)
|
||||
state.sync_db = False
|
||||
|
||||
def cleanup_lists():
|
||||
import item.models
|
||||
import user.models
|
||||
|
|
|
@ -598,6 +598,8 @@ class Nodes(Thread):
|
|||
def _pull(self):
|
||||
if not state.sync_enabled or settings.preferences.get('downloadRate') == 0:
|
||||
return
|
||||
if state.sync_db:
|
||||
return
|
||||
if state.activity and state.activity.get('activity') == 'import':
|
||||
return
|
||||
self._pulling = True
|
||||
|
|
|
@ -16,6 +16,7 @@ websockets = []
|
|||
uisockets = []
|
||||
peers = {}
|
||||
changelog_size = None
|
||||
sync_db = False
|
||||
|
||||
activity = {}
|
||||
removepeer = {}
|
||||
|
|
Loading…
Reference in a new issue