From f40f555d130c02be00a10644dce24b4eab25c1f1 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 10 Nov 2010 23:20:17 -0700 Subject: [PATCH] Fix #7491 (Error after subscribing to TidBITS: Mac News... news source) --- src/calibre/gui2/device.py | 8 +++++++- src/calibre/library/caches.py | 6 +++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/calibre/gui2/device.py b/src/calibre/gui2/device.py index 4e93335af6..8d84f69249 100644 --- a/src/calibre/gui2/device.py +++ b/src/calibre/gui2/device.py @@ -1014,7 +1014,13 @@ class DeviceMixin(object): # {{{ self.status_bar.show_message(_('Sent by email:') + ', '.join(good), 5000) if remove: - self.library_view.model().delete_books_by_id(remove) + try: + self.library_view.model().delete_books_by_id(remove) + except: + # Probably the user deleted the files, in any case, failing + # to delete the book is not catastrophic + traceback.print_exc() + def cover_to_thumbnail(self, data): ht = self.device_manager.device.THUMBNAIL_HEIGHT \ diff --git a/src/calibre/library/caches.py b/src/calibre/library/caches.py index 03383ee7dd..5f3e66beef 100644 --- a/src/calibre/library/caches.py +++ b/src/calibre/library/caches.py @@ -625,7 +625,11 @@ class ResultCache(SearchQueryParser): # {{{ # }}} def remove(self, id): - self._data[id] = None + try: + self._data[id] = None + except IndexError: + # id is out of bounds, no point setting it to None anyway + pass try: self._map.remove(id) except ValueError: