From 0f5a920e2012813330cf7ffe0c559cc48222810c Mon Sep 17 00:00:00 2001 From: Jan Szejko Date: Mon, 3 Jul 2017 14:54:42 +0200 Subject: [PATCH] snippet exception for non-existent book --- src/search/index.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/search/index.py b/src/search/index.py index c84841b19..7dfe6ef5a 100644 --- a/src/search/index.py +++ b/src/search/index.py @@ -827,8 +827,10 @@ class Search(SolrIndex): idx += 1 except IOError, e: - book = catalogue.models.Book.objects.get(id=book_id) - if not book.children.exists(): + book = catalogue.models.Book.objects.filter(id=book_id) + if not book: + log.error("Book does not exist for book id = %d" % book_id) + elif not book.get().children.exists(): log.error("Cannot open snippet file for book id = %d [rev=%s], %s" % (book_id, revision, e)) return [] finally: -- 2.20.1