diff --git a/oml/item/scan.py b/oml/item/scan.py index 632da9c..90e806a 100644 --- a/oml/item/scan.py +++ b/oml/item/scan.py @@ -134,7 +134,9 @@ def run_scan(): remove_missing(books) added = 0 + with db.session(): + user = state.user() for f in ox.sorted_strings(books): if state.shutdown: break @@ -144,6 +146,14 @@ def run_scan(): if not file: file = add_file(id, f, prefix, f) added += 1 + elif user not in file.item.users: + item = file.item + item.add_user(user) + logger.debug('add %s to local user', id) + add_record('additem', item.id, file.info) + add_record('edititem', item.id, item.meta) + item.update() + added += 1 if added: trigger_event('change', {}) logger.debug('imported %s unknown books', added)