From 10acaacbd97e7902c7b100a9b8c1677ffcee8434 Mon Sep 17 00:00:00 2001 From: j Date: Mon, 11 Jan 2016 19:59:55 +0530 Subject: [PATCH] cleanup orphan file records --- oml/item/scan.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/oml/item/scan.py b/oml/item/scan.py index c0c2a73..7be7207 100644 --- a/oml/item/scan.py +++ b/oml/item/scan.py @@ -33,10 +33,14 @@ def remove_missing(): for f in File.query: if not state.tasks.connected: return - path = f.item.get_path() - if not os.path.exists(path): + if f.item: + path = f.item.get_path() + if not os.path.exists(path): + dirty = True + f.item.remove_file() + else: + state.db.session.delete(f) dirty = True - f.item.remove_file() if dirty: state.db.session.commit()