mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Kobo driver: Improve performance when a large number of shelves are created on the device. Fixes #1066633 (Perfomance issues with kobo driver and shelves)
This commit is contained in:
parent
85212fb0c1
commit
eeeba5e40f
@ -58,6 +58,7 @@ class Book(Book_):
|
||||
self.datetime = time.gmtime()
|
||||
|
||||
self.contentID = None
|
||||
self.current_collections = []
|
||||
|
||||
if thumbnail_name is not None:
|
||||
self.thumbnail = ImageWrapper(thumbnail_name)
|
||||
@ -250,4 +251,3 @@ class KTCollectionsBookList(CollectionsBookList):
|
||||
# debug_print("KTCollectionsBookList:is_debugging - is_debugging=", is_debugging)
|
||||
|
||||
return is_debugging
|
||||
|
||||
|
@ -33,11 +33,11 @@ class KOBO(USBMS):
|
||||
gui_name = 'Kobo Reader'
|
||||
description = _('Communicate with the Kobo Reader')
|
||||
author = 'Timothy Legge and David Forrester'
|
||||
version = (2, 0, 1)
|
||||
version = (2, 0, 2)
|
||||
|
||||
dbversion = 0
|
||||
fwversion = 0
|
||||
supported_dbversion = 62
|
||||
supported_dbversion = 65
|
||||
has_kepubs = False
|
||||
|
||||
supported_platforms = ['windows', 'osx', 'linux']
|
||||
@ -217,7 +217,7 @@ class KOBO(USBMS):
|
||||
# print 'update_metadata_item returned true'
|
||||
changed = True
|
||||
else:
|
||||
debug_print(" Strange: The file: ", prefix, lpath, " does mot exist!")
|
||||
debug_print(" Strange: The file: ", prefix, lpath, " does mot exist!")
|
||||
if lpath in playlist_map and \
|
||||
playlist_map[lpath] not in bl[idx].device_collections:
|
||||
bl[idx].device_collections = playlist_map.get(lpath,[])
|
||||
@ -841,6 +841,14 @@ class KOBO(USBMS):
|
||||
|
||||
# debug_print('Finished update_device_database_collections', collections_attributes)
|
||||
|
||||
|
||||
def get_collections_attributes(self):
|
||||
collections = []
|
||||
opts = self.settings()
|
||||
if opts.extra_customization and len(opts.extra_customization[self.OPT_COLLECTIONS]) > 0:
|
||||
collections = [x.lower().strip() for x in opts.extra_customization[self.OPT_COLLECTIONS].split(',')]
|
||||
return collections
|
||||
|
||||
def sync_booklists(self, booklists, end_session=True):
|
||||
# debug_print('KOBO: started sync_booklists')
|
||||
paths = self.get_device_paths()
|
||||
@ -853,12 +861,7 @@ class KOBO(USBMS):
|
||||
blists[i] = booklists[i]
|
||||
except IndexError:
|
||||
pass
|
||||
opts = self.settings()
|
||||
if opts.extra_customization:
|
||||
collections = [x.lower().strip() for x in
|
||||
opts.extra_customization[self.OPT_COLLECTIONS].split(',')]
|
||||
else:
|
||||
collections = []
|
||||
collections = self.get_collections_attributes()
|
||||
|
||||
#debug_print('KOBO: collection fields:', collections)
|
||||
for i, blist in blists.items():
|
||||
@ -1447,6 +1450,7 @@ class KOBOTOUCH(KOBO):
|
||||
|
||||
if lpath in playlist_map:
|
||||
bl[idx].device_collections = playlist_map.get(lpath,[])
|
||||
bl[idx].current_collections = bl[idx].device_collections
|
||||
changed = True
|
||||
|
||||
if show_debug:
|
||||
@ -1483,6 +1487,7 @@ class KOBOTOUCH(KOBO):
|
||||
|
||||
# print 'Update booklist'
|
||||
book.device_collections = playlist_map.get(lpath,[])# if lpath in playlist_map else []
|
||||
book.current_collections = bl[idx].device_collections
|
||||
book.contentID = ContentID
|
||||
# debug_print('KoboTouch:update_booklist - title=', title, 'book.device_collections', book.device_collections)
|
||||
|
||||
@ -1944,6 +1949,7 @@ class KOBOTOUCH(KOBO):
|
||||
if self.supports_bookshelves():
|
||||
debug_print("KoboTouch:update_device_database_collections - managing bookshelves.")
|
||||
if bookshelf_attribute:
|
||||
debug_print("KoboTouch:update_device_database_collections - bookshelf_attribute=", bookshelf_attribute)
|
||||
for book in booklists:
|
||||
if book.application_id is not None:
|
||||
# debug_print("KoboTouch:update_device_database_collections - about to remove a book from shelves book.title=%s" % book.title)
|
||||
@ -1958,11 +1964,7 @@ class KOBOTOUCH(KOBO):
|
||||
|
||||
def rebuild_collections(self, booklist, oncard):
|
||||
debug_print("KoboTouch:rebuild_collections")
|
||||
collections_attributes = []
|
||||
opts = self.settings()
|
||||
if opts.extra_customization:
|
||||
collections_attributes = [x.strip() for x in
|
||||
opts.extra_customization[self.OPT_COLLECTIONS].split(',')]
|
||||
collections_attributes = self.get_collections_attributes()
|
||||
|
||||
debug_print('KoboTouch:rebuild_collections: collection fields:', collections_attributes)
|
||||
self.update_device_database_collections(booklist, collections_attributes, oncard)
|
||||
@ -2086,12 +2088,17 @@ class KOBOTOUCH(KOBO):
|
||||
|
||||
def remove_book_from_device_bookshelves(self, connection, book):
|
||||
show_debug = self.is_debugging_title(book.title)# or True
|
||||
|
||||
remove_shelf_list = set(book.current_collections) - set(book.device_collections) - set(["Im_Reading", "Read", "Closed"])
|
||||
|
||||
if show_debug:
|
||||
debug_print('KoboTouch:remove_book_from_device_bookshelves - book.in_library="%s"'%book.application_id)
|
||||
debug_print('KoboTouch:remove_book_from_device_bookshelves - book.application_id="%s"'%book.application_id)
|
||||
debug_print('KoboTouch:remove_book_from_device_bookshelves - book.contentID="%s"'%book.contentID)
|
||||
debug_print('KoboTouch:remove_book_from_device_bookshelves - book.device_collections=', book.device_collections)
|
||||
|
||||
debug_print('KoboTouch:remove_book_from_device_bookshelves - remove_shelf_list=', remove_shelf_list)
|
||||
|
||||
if len(remove_shelf_list) == 0:
|
||||
return
|
||||
|
||||
query = 'DELETE FROM ShelfContent WHERE ContentId = ?'
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user