mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Content server: Ignore current VL in GUI when embedded
Content server: When running from inside the main calibre program, do not restrict the books shown based on the current virtual library in the main program. If you wish to restrict the books shown in the content server, use Preferences->Sharing over the net.
This commit is contained in:
parent
7905b2e4ef
commit
a4f2d0d664
@ -590,8 +590,7 @@ class AjaxServer(object):
|
||||
|
||||
if isbytestring(query):
|
||||
query = query.decode('UTF-8')
|
||||
ids = self.db.search_getting_ids(query.strip(), self.search_restriction, sort_results=False)
|
||||
ids = list(ids)
|
||||
ids = list(self.search_for_books(query))
|
||||
self.db.data.multisort(fields=[(sfield, sort_order == 'asc')], subsort=True,
|
||||
only_ids=ids)
|
||||
total_num = len(ids)
|
||||
|
@ -314,3 +314,9 @@ class LibraryServer(ContentServer, MobileServer, XMLServer, OPDSServer, Cache,
|
||||
t.daemon = True
|
||||
t.start()
|
||||
|
||||
def search_for_books(self, query):
|
||||
return self.db.search_getting_ids(
|
||||
(query or '').strip(), self.search_restriction,
|
||||
sort_results=False, use_virtual_library=False)
|
||||
|
||||
|
||||
|
@ -931,8 +931,7 @@ class BrowseServer(object):
|
||||
def browse_random(self, *args, **kwargs):
|
||||
import random
|
||||
try:
|
||||
book_id = random.choice(self.db.search_getting_ids(
|
||||
'', self.search_restriction, sort_results=False))
|
||||
book_id = random.choice(self.search_for_books(''))
|
||||
except IndexError:
|
||||
raise cherrypy.HTTPError(404, 'This library has no books')
|
||||
ans = self.browse_render_details(book_id, add_random_button=True)
|
||||
@ -957,7 +956,7 @@ class BrowseServer(object):
|
||||
def browse_search(self, query='', list_sort=None):
|
||||
if isbytestring(query):
|
||||
query = query.decode('UTF-8')
|
||||
ids = self.db.search_getting_ids(query.strip(), self.search_restriction)
|
||||
ids = self.search_for_books(query)
|
||||
items = [self.db.data.tablerow_for_id(x) for x in ids]
|
||||
sort = self.browse_sort_book_list(items, list_sort)
|
||||
ids = [x[0] for x in items]
|
||||
|
@ -21,9 +21,7 @@ class Cache(object):
|
||||
def search_cache(self, search):
|
||||
old = self._search_cache.pop(search, None)
|
||||
if old is None or old[0] <= self.db.last_modified():
|
||||
matches = self.db.data.search_getting_ids(search, self.search_restriction, sort_results=False)
|
||||
if not matches:
|
||||
matches = []
|
||||
matches = self.search_for_books(search) or []
|
||||
self._search_cache[search] = (utcnow(), frozenset(matches))
|
||||
if len(self._search_cache) > 50:
|
||||
self._search_cache.popitem(last=False)
|
||||
|
@ -222,7 +222,7 @@ class MobileServer(object):
|
||||
search = ''
|
||||
if isbytestring(search):
|
||||
search = search.decode('UTF-8')
|
||||
ids = self.db.search_getting_ids(search.strip(), self.search_restriction, sort_results=False)
|
||||
ids = self.search_for_books(search)
|
||||
FM = self.db.FIELD_MAP
|
||||
items = [r for r in iter(self.db) if r[FM['id']] in ids]
|
||||
if sort is not None:
|
||||
|
@ -53,7 +53,7 @@ class XMLServer(object):
|
||||
if isbytestring(search):
|
||||
search = search.decode('UTF-8')
|
||||
|
||||
ids = self.db.search_getting_ids(search.strip(), self.search_restriction, sort_results=False)
|
||||
ids = self.search_for_books(search)
|
||||
|
||||
FM = self.db.FIELD_MAP
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user