py3: Fix #1850571 [[Python3] kobo driver fails to load](https://bugs.launchpad.net/calibre/+bug/1850571)

This commit is contained in:
Kovid Goyal 2019-10-30 08:28:14 +05:30
parent 55033c352d
commit 21afbdc1d6
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -408,7 +408,7 @@ class KOBO(USBMS):
# Remove books that are no longer in the filesystem. Cache contains # Remove books that are no longer in the filesystem. Cache contains
# indices into the booklist if book not in filesystem, None otherwise # indices into the booklist if book not in filesystem, None otherwise
# Do the operation in reverse order so indices remain valid # Do the operation in reverse order so indices remain valid
for idx in sorted(itervalues(bl_cache), reverse=True): for idx in sorted(itervalues(bl_cache), reverse=True, key=lambda x: x or -1):
if idx is not None: if idx is not None:
need_sync = True need_sync = True
del bl[idx] del bl[idx]
@ -1971,7 +1971,7 @@ class KOBOTOUCH(KOBO):
# Remove books that are no longer in the filesystem. Cache contains # Remove books that are no longer in the filesystem. Cache contains
# indices into the booklist if book not in filesystem, None otherwise # indices into the booklist if book not in filesystem, None otherwise
# Do the operation in reverse order so indices remain valid # Do the operation in reverse order so indices remain valid
for idx in sorted(itervalues(bl_cache), reverse=True): for idx in sorted(itervalues(bl_cache), reverse=True, key=lambda x: x or -1):
if idx is not None: if idx is not None:
if not os.path.exists(self.normalize_path(os.path.join(prefix, bl[idx].lpath))) or not bl[idx].contentID: if not os.path.exists(self.normalize_path(os.path.join(prefix, bl[idx].lpath))) or not bl[idx].contentID:
need_sync = True need_sync = True