From c73123fceea166c7ff1a0d096ad7d576abb4820c Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 25 Jul 2013 11:26:38 +0530 Subject: [PATCH] Fix deleting books in newdb --- src/calibre/db/legacy.py | 3 ++- src/calibre/db/view.py | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/calibre/db/legacy.py b/src/calibre/db/legacy.py index efb71223a2..b2ac69c13a 100644 --- a/src/calibre/db/legacy.py +++ b/src/calibre/db/legacy.py @@ -320,8 +320,9 @@ class LibraryDatabase(object): def delete_book(self, book_id, notify=True, commit=True, permanent=False, do_clean=True): self.new_api.remove_books((book_id,), permanent=permanent) + self.data.books_deleted((book_id,)) if notify: - self.notify('delete', [id]) + self.notify('delete', [book_id]) def dirtied(self, book_ids, commit=True): self.new_api.mark_as_dirty(frozenset(book_ids) if book_ids is not None else book_ids) diff --git a/src/calibre/db/view.py b/src/calibre/db/view.py index 602a2fbeaf..8c99cf41cf 100644 --- a/src/calibre/db/view.py +++ b/src/calibre/db/view.py @@ -339,3 +339,17 @@ class View(object): pass return None + def remove(self, book_id): + try: + self._map = tuple(bid for bid in self._map if bid != book_id) + except ValueError: + pass + try: + self._map_filtered = tuple(bid for bid in self._map_filtered if bid != book_id) + except ValueError: + pass + + def books_deleted(self, ids): + for book_id in ids: + self.remove(book_id) +