diff --git a/oml/library.py b/oml/library.py index fe321ff..9e49c55 100644 --- a/oml/library.py +++ b/oml/library.py @@ -311,6 +311,7 @@ class Peer(object): def sync_db(): from sqlalchemy.orm import load_only import item.models + first = True with db.session(): sort_ids = {i.item_id for i in item.models.Sort.query.options(load_only('item_id'))} if sort_ids: @@ -318,6 +319,9 @@ def sync_db(): commit = False for i in item.models.Item.query.options(load_only('id')): if i.id not in sort_ids: + if first: + first = False + logger.debug('sync items') i.update(commit=False) if i.info['mediastate'] == 'unavailable' and state.tasks: state.tasks.queue('getpreview', i.id) @@ -328,6 +332,8 @@ def sync_db(): break if commit: state.db.session.commit() + if not first: + logger.debug('synced items') if not state.shutdown: cleanup_lists() if not state.shutdown: