From 8766c7ef4eb1fe65111d3b2af4f18e6ac34660df Mon Sep 17 00:00:00 2001 From: j Date: Wed, 3 Feb 2021 10:19:17 +0100 Subject: [PATCH] checking item can faile with sqlalchemy.orm.exc.ObjectDeletedError --- oml/item/models.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/oml/item/models.py b/oml/item/models.py index 3037245..61732d1 100644 --- a/oml/item/models.py +++ b/oml/item/models.py @@ -733,7 +733,13 @@ class File(db.Model): return re.sub(r'^\.|\.$|:|/|\?|<|>|\\|\*|\||"', '_', string) prefs = settings.preferences prefix = os.sep.join(os.path.join(os.path.expanduser(prefs['libraryPath']), 'Books/').split('/')) - if not self.item: + not_item = False + try: + not_item = not self.item + except: + logger.debug('trying to move an item that was just deleted', exc_info=True) + not_item = True + if not_item: return j = self.item.json(keys=['title', 'author', 'publisher', 'date', 'extension'])