Skip to content

Commit

Permalink
Fix for regression in 2.3 connecting with Calibre Companion when dele…
Browse files Browse the repository at this point in the history
…ting books caused by the performance improvement in 829447f
  • Loading branch information
kovidgoyal committed Sep 12, 2014
1 parent 2002b18 commit 6925fd7
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/calibre/devices/smart_device_app/driver.py
Expand Up @@ -1272,7 +1272,7 @@ def books(self, oncard=None, end_session=True):
self._debug('processed cache. count=', len(books_on_device))
count_of_cache_items_deleted = 0
if self.client_cache_uses_lpaths:
for lpath in self.known_metadata.iterkeys():
for lpath in tuple(self.known_metadata.iterkeys()):
if lpath not in lpaths_on_device:
try:
uuid = self.known_metadata[lpath].get('uuid', None)
Expand Down Expand Up @@ -1569,7 +1569,6 @@ def _check_if_format_send_needed(self, db, id_, book):
traceback.print_exc()
return None


@synchronous('sync_lock')
def synchronize_with_db(self, db, id_, book):
from calibre.utils.date import parse_date, is_date_undefined
Expand Down

2 comments on commit 6925fd7

@cbhaley
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Using tuple() creates a copy of the iterator and not list of keys? That is a new one for me. :)

Could you let me know when the new version is up so I can pass that info on?

@kovidgoyal
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's up now.

Using tuple makes it explicit that you want to operate on a copy of the set of keys in the dict, rather than relying on the behavior of the keys() method (which IIRC changes in python 3 to use an iterator).

Please sign in to comment.