mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Merge branch 'master' of https://github.com/cbhaley/calibre
This commit is contained in:
commit
9b492bfcd6
@ -607,7 +607,8 @@ class Cache(object):
|
||||
if not fmt:
|
||||
return {}
|
||||
fmt = fmt.upper()
|
||||
if allow_cache:
|
||||
# allow_cache and update_db are mutually exclusive. Give priority to update_db
|
||||
if allow_cache and not update_db:
|
||||
x = self.format_metadata_cache[book_id].get(fmt, None)
|
||||
if x is not None:
|
||||
return x
|
||||
@ -635,6 +636,11 @@ class Cache(object):
|
||||
fmts = field.table.book_col_map.get(book_id, ())
|
||||
return {fmt:field.format_fname(book_id, fmt) for fmt in fmts}
|
||||
|
||||
@read_api
|
||||
def format_db_size(self, book_id, fmt):
|
||||
field = self.fields['formats']
|
||||
return field.format_size(book_id, fmt)
|
||||
|
||||
@read_api
|
||||
def pref(self, name, default=None, namespace=None):
|
||||
' Return the value for the specified preference or the value specified as ``default`` if the preference is not set. '
|
||||
|
@ -623,6 +623,9 @@ class FormatsField(ManyToManyField):
|
||||
def format_fname(self, book_id, fmt):
|
||||
return self.table.fname_map[book_id][fmt.upper()]
|
||||
|
||||
def format_size(self, book_id, fmt):
|
||||
return self.table.size_map.get(book_id, {}).get(fmt.upper(), None)
|
||||
|
||||
def iter_searchable_values(self, get_metadata, candidates, default_value=None):
|
||||
val_map = defaultdict(set)
|
||||
cbm = self.table.book_col_map
|
||||
|
Loading…
x
Reference in New Issue
Block a user