From 07300f83f346af9a98a742cdca200f8ef68f3045 Mon Sep 17 00:00:00 2001 From: j Date: Sat, 12 Jan 2019 22:34:15 +0530 Subject: [PATCH] add lost items --- oml/item/scan.py | 10 ++++++++++ 1 file changed, 10 insertions(+) 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)