mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
...
This commit is contained in:
parent
86d0715e71
commit
e6c651c5bf
@ -926,7 +926,7 @@ class Search(object):
|
|||||||
finally:
|
finally:
|
||||||
sqp.dbcache = sqp.lookup_saved_search = None
|
sqp.dbcache = sqp.lookup_saved_search = None
|
||||||
|
|
||||||
def _use_cache(self, sqp, dbcache, query):
|
def query_is_cacheable(self, sqp, dbcache, query):
|
||||||
if query:
|
if query:
|
||||||
for name, value in sqp.get_queried_fields(query):
|
for name, value in sqp.get_queried_fields(query):
|
||||||
if name == 'template' and '#@#:d:' in value:
|
if name == 'template' and '#@#:d:' in value:
|
||||||
@ -949,7 +949,7 @@ class Search(object):
|
|||||||
query = query.decode('utf-8')
|
query = query.decode('utf-8')
|
||||||
|
|
||||||
query = query.strip()
|
query = query.strip()
|
||||||
use_cache = self._use_cache(sqp, dbcache, query)
|
use_cache = self.query_is_cacheable(sqp, dbcache, query)
|
||||||
|
|
||||||
if use_cache and book_ids is None and query and not search_restriction:
|
if use_cache and book_ids is None and query and not search_restriction:
|
||||||
cached = self.cache.get(query)
|
cached = self.cache.get(query)
|
||||||
@ -960,7 +960,7 @@ class Search(object):
|
|||||||
if search_restriction and search_restriction.strip():
|
if search_restriction and search_restriction.strip():
|
||||||
sr = search_restriction.strip()
|
sr = search_restriction.strip()
|
||||||
sqp.all_book_ids = all_book_ids if book_ids is None else book_ids
|
sqp.all_book_ids = all_book_ids if book_ids is None else book_ids
|
||||||
if self._use_cache(sqp, dbcache, sr):
|
if self.query_is_cacheable(sqp, dbcache, sr):
|
||||||
cached = self.cache.get(sr)
|
cached = self.cache.get(sr)
|
||||||
if cached is None:
|
if cached is None:
|
||||||
restricted_ids = sqp.parse(sr)
|
restricted_ids = sqp.parse(sr)
|
||||||
|
@ -351,7 +351,7 @@ class SearchQueryParser(object):
|
|||||||
yield from self._walk_expr(self._get_tree(
|
yield from self._walk_expr(self._get_tree(
|
||||||
self._get_saved_search_text(tree[2])))
|
self._get_saved_search_text(tree[2])))
|
||||||
else:
|
else:
|
||||||
yield (tree[1], tree[2])
|
yield tree[1], tree[2]
|
||||||
|
|
||||||
def parse(self, query, candidates=None):
|
def parse(self, query, candidates=None):
|
||||||
# empty the list of searches used for recursion testing
|
# empty the list of searches used for recursion testing
|
||||||
|
Loading…
x
Reference in New Issue
Block a user