From 9ae9cf219ecd17d4552e25fcb4c466c5f35778ec Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 25 Jul 2013 12:12:46 +0530 Subject: [PATCH] newdb: Fix reloading of content server on metadata.db change --- src/calibre/db/__init__.py | 2 +- src/calibre/db/legacy.py | 1 + src/calibre/db/view.py | 5 +++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/calibre/db/__init__.py b/src/calibre/db/__init__.py index bb0f679fd8..ceb6485efc 100644 --- a/src/calibre/db/__init__.py +++ b/src/calibre/db/__init__.py @@ -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) ''' diff --git a/src/calibre/db/legacy.py b/src/calibre/db/legacy.py index f85340aacd..3da725fe7e 100644 --- a/src/calibre/db/legacy.py +++ b/src/calibre/db/legacy.py @@ -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 diff --git a/src/calibre/db/view.py b/src/calibre/db/view.py index 48d53e06a8..f679fc2416 100644 --- a/src/calibre/db/view.py +++ b/src/calibre/db/view.py @@ -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: