No device collections if shelves not maintained

Kobo driver: Display device collections even if the driver is configured
to not manage shelves on the device. Fixes #1214233 [Collections are empty when not maintaining shelves on Kobo devices](https://bugs.launchpad.net/calibre/+bug/1214233)

Skip getting the shelf collections if the Kobo driver is not configured
to maintain them. This was wiping out the device collections.
This commit is contained in:
David Forrester 2013-08-20 14:29:11 +10:00 committed by Kovid Goyal
parent c65f952f0f
commit 55e8c029e7

View File

@ -44,7 +44,7 @@ class KOBO(USBMS):
gui_name = 'Kobo Reader' gui_name = 'Kobo Reader'
description = _('Communicate with the Kobo Reader') description = _('Communicate with the Kobo Reader')
author = 'Timothy Legge and David Forrester' author = 'Timothy Legge and David Forrester'
version = (2, 1, 0) version = (2, 1, 1)
dbversion = 0 dbversion = 0
fwversion = 0 fwversion = 0
@ -2112,9 +2112,6 @@ class KOBOTOUCH(KOBO):
create_bookshelves = False create_bookshelves = False
update_series_details = False update_series_details = False
collections = booklists.get_collections(collections_attributes)
# debug_print('KoboTouch:update_device_database_collections - Collections:', collections)
opts = self.settings() opts = self.settings()
if opts.extra_customization: if opts.extra_customization:
create_bookshelves = opts.extra_customization[self.OPT_CREATE_BOOKSHELVES] and self.supports_bookshelves() create_bookshelves = opts.extra_customization[self.OPT_CREATE_BOOKSHELVES] and self.supports_bookshelves()
@ -2123,6 +2120,9 @@ class KOBOTOUCH(KOBO):
delete_empty_shelves = False delete_empty_shelves = False
bookshelf_attribute = len(collections_attributes) bookshelf_attribute = len(collections_attributes)
collections = booklists.get_collections(collections_attributes) if bookshelf_attribute else None
# debug_print('KoboTouch:update_device_database_collections - Collections:', collections)
# Create a connection to the sqlite database # Create a connection to the sqlite database
# Needs to be outside books collection as in the case of removing # Needs to be outside books collection as in the case of removing
# the last book from the collection the list of books is empty # the last book from the collection the list of books is empty
@ -2551,11 +2551,11 @@ class KOBOTOUCH(KOBO):
if show_debug: if show_debug:
debug_print(' Did not find a record - adding') debug_print(' Did not find a record - adding')
cursor.execute(addquery, add_values) cursor.execute(addquery, add_values)
connection.commit()
elif result[0] == 'true': elif result[0] == 'true':
if show_debug: if show_debug:
debug_print(' Found a record - updating - result=', result) debug_print(' Found a record - updating - result=', result)
cursor.execute(updatequery, update_values) cursor.execute(updatequery, update_values)
connection.commit() connection.commit()
cursor.close() cursor.close()