newdb: Fix reloading of content server on metadata.db change

This commit is contained in:
Kovid Goyal 2013-07-25 12:12:46 +05:30
parent 179c28e328
commit 9ae9cf219e
3 changed files with 5 additions and 3 deletions

View File

@ -137,7 +137,7 @@ def get_db_loader():
'''
Various things that require other things before they can be migrated:
1. Check that content server reloading on metadata,db change, metadata
1. Check that metadata
backup, refresh gui on calibredb add and moving libraries all work (check
them on windows as well for file locking issues)
'''

View File

@ -120,6 +120,7 @@ class LibraryDatabase(object):
if self.last_modified() > self.last_update_check:
self.backend.reopen()
self.new_api.reload_from_db()
self.data.refresh(clear_caches=False) # caches are already cleared by reload_from_db()
self.last_update_check = utcnow()
@property

View File

@ -322,10 +322,11 @@ class View(object):
# be shared by multiple views. This is not ideal, but...
self.cache.clear_search_caches(old_marked_ids | set(self.marked_ids))
def refresh(self, field=None, ascending=True):
def refresh(self, field=None, ascending=True, clear_caches=True):
self._map = tuple(self.cache.all_book_ids())
self._map_filtered = tuple(self._map)
self.cache.clear_caches()
if clear_caches:
self.cache.clear_caches()
if field is not None:
self.sort(field, ascending)
if self.search_restriction or self.base_restriction: