From 47647a7b861857eaf5bb345b7c302d90823dfe47 Mon Sep 17 00:00:00 2001 From: j Date: Mon, 28 Mar 2016 15:51:08 +0200 Subject: [PATCH] cleanup broken file db entries --- oml/item/scan.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/oml/item/scan.py b/oml/item/scan.py index da62ef8..c5093f6 100644 --- a/oml/item/scan.py +++ b/oml/item/scan.py @@ -41,7 +41,14 @@ def remove_missing(books=None): return path = f.fullpath() db_paths.append(path) - items[path] = f.sha1 + if f.item: + items[path] = f.sha1 + else: + state.db.session.delete(f) + dirty = True + if dirty: + state.db.session.commit() + dirty = False removed = set(db_paths) - set(books) if removed: logger.debug('%s files removed', len(removed))