mirror of https://github.com/kiwix/libkiwix.git
Handle book without xapian index.
This commit is contained in:
parent
1962262f94
commit
3641dbf14d
|
@ -566,6 +566,7 @@ std::unique_ptr<Response> InternalServer::handle_search(const RequestContext& re
|
||||||
/* Make the search */
|
/* Make the search */
|
||||||
// Try to get a search from the searchInfo, else build it
|
// Try to get a search from the searchInfo, else build it
|
||||||
std::shared_ptr<zim::Search> search;
|
std::shared_ptr<zim::Search> search;
|
||||||
|
try {
|
||||||
search = searchCache.getOrPut(searchInfo,
|
search = searchCache.getOrPut(searchInfo,
|
||||||
[=](){
|
[=](){
|
||||||
std::shared_ptr<zim::Searcher> searcher;
|
std::shared_ptr<zim::Searcher> searcher;
|
||||||
|
@ -586,6 +587,15 @@ std::unique_ptr<Response> InternalServer::handle_search(const RequestContext& re
|
||||||
return make_shared<zim::Search>(searcher->search(searchInfo.getZimQuery(m_verbose.load())));
|
return make_shared<zim::Search>(searcher->search(searchInfo.getZimQuery(m_verbose.load())));
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
} catch(std::runtime_error& e) {
|
||||||
|
// Searcher->search will throw a runtime error if there is no valid xapian database to do the search.
|
||||||
|
// (in case of zim file not containing a index)
|
||||||
|
auto data = get_default_data();
|
||||||
|
data.set("pattern", encodeDiples(searchInfo.pattern));
|
||||||
|
auto response = ContentResponse::build(*this, RESOURCE::templates::no_search_result_html, data, "text/html; charset=utf-8");
|
||||||
|
response->set_code(MHD_HTTP_NOT_FOUND);
|
||||||
|
return withTaskbarInfo(searchInfo.bookName, archive.get(), std::move(response));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
auto start = 0;
|
auto start = 0;
|
||||||
|
|
Loading…
Reference in New Issue