On device column: Only use metadata based matching if the book on the device does not have a uuid, or its uuid is not in the current library

This commit is contained in:
Kovid Goyal 2010-09-09 17:57:58 -06:00
parent 10d5d64590
commit 6e24780d47

View File

@ -1343,7 +1343,8 @@ class DeviceMixin(object): # {{{
if book_title not in self.book_db_title_cache[i]: if book_title not in self.book_db_title_cache[i]:
self.book_db_title_cache[i][book_title] = \ self.book_db_title_cache[i][book_title] = \
{'authors':set(), 'db_ids':set(), {'authors':set(), 'db_ids':set(),
'uuids':set(), 'paths':set()} 'uuids':set(), 'paths':set(),
'uuid_in_library':False}
book_authors = clean_string(authors_to_string(book.authors)) book_authors = clean_string(authors_to_string(book.authors))
self.book_db_title_cache[i][book_title]['authors'].add(book_authors) self.book_db_title_cache[i][book_title]['authors'].add(book_authors)
db_id = getattr(book, 'application_id', None) db_id = getattr(book, 'application_id', None)
@ -1359,6 +1360,9 @@ class DeviceMixin(object): # {{{
if uuid is not None: if uuid is not None:
self.book_db_uuid_cache[i].add(uuid) self.book_db_uuid_cache[i].add(uuid)
self.book_db_uuid_path_map[uuid] = book.path self.book_db_uuid_path_map[uuid] = book.path
if uuid in self.db_book_uuid_cache:
self.book_db_title_cache[i][book_title]\
['uuid_in_library'] = True
self.book_db_title_cache[i][book_title]['paths'].add(book.path) self.book_db_title_cache[i][book_title]['paths'].add(book.path)
mi = self.library_view.model().db.get_metadata(id, index_is_id=True) mi = self.library_view.model().db.get_metadata(id, index_is_id=True)
@ -1370,7 +1374,7 @@ class DeviceMixin(object): # {{{
continue continue
db_title = clean_string(mi.title) db_title = clean_string(mi.title)
cache = self.book_db_title_cache[i].get(db_title, None) cache = self.book_db_title_cache[i].get(db_title, None)
if cache: if cache and not cache['uuid_in_library']:
if id in cache['db_ids']: if id in cache['db_ids']:
loc[i] = True loc[i] = True
loc[4] = 'db_id' loc[4] = 'db_id'