Fix deleting books in newdb

This commit is contained in:
Kovid Goyal 2013-07-25 11:26:38 +05:30
parent 2b8dc4505d
commit c73123fcee
2 changed files with 16 additions and 1 deletions

View File

@ -320,8 +320,9 @@ class LibraryDatabase(object):
def delete_book(self, book_id, notify=True, commit=True, permanent=False, do_clean=True): 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.new_api.remove_books((book_id,), permanent=permanent)
self.data.books_deleted((book_id,))
if notify: if notify:
self.notify('delete', [id]) self.notify('delete', [book_id])
def dirtied(self, book_ids, commit=True): 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) self.new_api.mark_as_dirty(frozenset(book_ids) if book_ids is not None else book_ids)

View File

@ -339,3 +339,17 @@ class View(object):
pass pass
return None 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)