mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-08-11 09:13:57 -04:00
Invalidate composite column caches when settinf fields
This commit is contained in:
parent
96d71be87d
commit
c936ad2c1c
@ -620,7 +620,6 @@ class Cache(object):
|
|||||||
@write_api
|
@write_api
|
||||||
def set_field(self, name, book_id_to_val_map, allow_case_change=True):
|
def set_field(self, name, book_id_to_val_map, allow_case_change=True):
|
||||||
# TODO: Specialize title/authors to also update path
|
# TODO: Specialize title/authors to also update path
|
||||||
# TODO: Handle updating caches used by composite fields
|
|
||||||
# TODO: Ensure the sort fields are updated for title/author/series?
|
# TODO: Ensure the sort fields are updated for title/author/series?
|
||||||
f = self.fields[name]
|
f = self.fields[name]
|
||||||
is_series = f.metadata['datatype'] == 'series'
|
is_series = f.metadata['datatype'] == 'series'
|
||||||
@ -646,6 +645,10 @@ class Cache(object):
|
|||||||
sf = self.fields[f.name+'_index']
|
sf = self.fields[f.name+'_index']
|
||||||
dirtied |= sf.writer.set_books(simap, self.backend, allow_case_change=False)
|
dirtied |= sf.writer.set_books(simap, self.backend, allow_case_change=False)
|
||||||
|
|
||||||
|
if dirtied and self.composites:
|
||||||
|
for name in self.composites:
|
||||||
|
self.fields[name].pop_cache(dirtied)
|
||||||
|
|
||||||
return dirtied
|
return dirtied
|
||||||
|
|
||||||
# }}}
|
# }}}
|
||||||
|
@ -167,8 +167,9 @@ class CompositeField(OneToOneField):
|
|||||||
with self._lock:
|
with self._lock:
|
||||||
self._render_cache = {}
|
self._render_cache = {}
|
||||||
|
|
||||||
def pop_cache(self, book_id):
|
def pop_cache(self, book_ids):
|
||||||
with self._lock:
|
with self._lock:
|
||||||
|
for book_id in book_ids:
|
||||||
self._render_cache.pop(book_id, None)
|
self._render_cache.pop(book_id, None)
|
||||||
|
|
||||||
def get_value_with_cache(self, book_id, get_metadata):
|
def get_value_with_cache(self, book_id, get_metadata):
|
||||||
@ -177,6 +178,8 @@ class CompositeField(OneToOneField):
|
|||||||
if ans is None:
|
if ans is None:
|
||||||
mi = get_metadata(book_id)
|
mi = get_metadata(book_id)
|
||||||
ans = mi.get('#'+self.metadata['label'])
|
ans = mi.get('#'+self.metadata['label'])
|
||||||
|
with self._lock:
|
||||||
|
self._render_cache[book_id] = ans
|
||||||
return ans
|
return ans
|
||||||
|
|
||||||
def sort_keys_for_books(self, get_metadata, lang_map, all_book_ids):
|
def sort_keys_for_books(self, get_metadata, lang_map, all_book_ids):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user