From e6b663f96609802f7b14adf0e5babb842efa0634 Mon Sep 17 00:00:00 2001 From: David Forrester Date: Wed, 25 Sep 2013 11:22:05 +1000 Subject: [PATCH] Reading status wiped for older Kobo Touch firmware When a Kobo Touch running a 1.9.x firmware was connected, the reading status of all books was wiped out. This was to do with the way the collections were managed. If a shelf/collection attribute was not defined, the reading status was being cleared when it should not have been. Also skipping a loop over the books if shelf and series management is not being done. --- src/calibre/devices/kobo/driver.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/calibre/devices/kobo/driver.py b/src/calibre/devices/kobo/driver.py index f93cb18..e8985b1 100644 --- a/src/calibre/devices/kobo/driver.py +++ b/src/calibre/devices/kobo/driver.py @@ -792,6 +792,7 @@ class KOBO(USBMS): # debug_print(' Commit: Set FavouritesIndex') def update_device_database_collections(self, booklists, collections_attributes, oncard): + debug_print("Kobo:update_device_database_collections - oncard='%s'"%oncard) if self.modify_database_check("update_device_database_collections") == False: return @@ -822,7 +823,7 @@ class KOBO(USBMS): collections_attributes = ['tags'] collections = booklists.get_collections(collections_attributes) -# debug_print('Collections', collections) +# debug_print('Kobo:update_device_database_collections - Collections:', collections) # Create a connection to the sqlite database # Needs to be outside books collection as in the case of removing @@ -2171,8 +2172,10 @@ class KOBOTOUCH(KOBO): # Need to reset the collections outside the particular loops # otherwise the last item will not be removed if self.dbversion < 53: + debug_print("KoboTouch:update_device_database_collections - calling reset_readstatus") self.reset_readstatus(connection, oncard) if self.dbversion >= 14: + debug_print("KoboTouch:update_device_database_collections - calling reset_favouritesindex") self.reset_favouritesindex(connection, oncard) # debug_print("KoboTouch:update_device_database_collections - length collections=", len(collections)) @@ -2240,7 +2243,7 @@ class KOBOTOUCH(KOBO): debug_print(' category not added to book.device_collections', book.device_collections) debug_print("KoboTouch:update_device_database_collections - end for category='%s'"%category) - else: # No collections + elif bookshelf_attribute: # No collections but have set the shelf option # Since no collections exist the ReadStatus needs to be reset to 0 (Unread) debug_print("No Collections - reseting ReadStatus") if self.dbversion < 53: @@ -2249,7 +2252,8 @@ class KOBOTOUCH(KOBO): debug_print("No Collections - resetting FavouritesIndex") self.reset_favouritesindex(connection, oncard) - if self.supports_bookshelves() or self.supports_series(): + # Set the series info and cleanup the bookshelves only if the firmware supports them and the user has set the options. + if (self.supports_bookshelves() or self.supports_series()) and (bookshelf_attribute or update_series_details): debug_print("KoboTouch:update_device_database_collections - managing bookshelves and series.") self.series_set = 0 -- 1.8.3.msysgit.0