snippet exception for non-existent book
authorJan Szejko <janek37@gmail.com>
Mon, 3 Jul 2017 12:54:42 +0000 (14:54 +0200)
committerJan Szejko <janek37@gmail.com>
Mon, 3 Jul 2017 12:54:42 +0000 (14:54 +0200)
src/search/index.py

index c84841b..7dfe6ef 100644 (file)
@@ -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: