From db00f1887c50aa63233721f757f1369bb21f0168 Mon Sep 17 00:00:00 2001 From: davidfor Date: Wed, 19 Dec 2012 13:45:53 +1100 Subject: [PATCH] Due to a problem with the Kobo server, some shelve were synced with null values in the names. This shouldn't happen, but adding some checking for this so that it doesn't break things. --- src/calibre/devices/kobo/books.py | 5 +++++ src/calibre/devices/kobo/driver.py | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/calibre/devices/kobo/books.py b/src/calibre/devices/kobo/books.py index bcf6353e83..fc18a61fc8 100644 --- a/src/calibre/devices/kobo/books.py +++ b/src/calibre/devices/kobo/books.py @@ -199,6 +199,11 @@ class KTCollectionsBookList(CollectionsBookList): ('series' in collection_attributes and book.get('series', None) == category): is_series = True + + # The category should not be None, but, it has happened. + if not category: + continue + cat_name = category.strip(' ,') if cat_name not in collections: diff --git a/src/calibre/devices/kobo/driver.py b/src/calibre/devices/kobo/driver.py index 0aa946c848..2932c657b0 100644 --- a/src/calibre/devices/kobo/driver.py +++ b/src/calibre/devices/kobo/driver.py @@ -1537,7 +1537,11 @@ class KOBOTOUCH(KOBO): return bookshelves cursor = connection.cursor() - query = "select ShelfName from ShelfContent where ContentId = ? and _IsDeleted = 'false'" + query = "select ShelfName " \ + "from ShelfContent " \ + "where ContentId = ? " \ + "and _IsDeleted = 'false' " \ + "and ShelfName is not null" # This should never be nulll, but it is protection against an error cause by a sync to the Kobo server values = (ContentID, ) cursor.execute(query, values) for i, row in enumerate(cursor):