mirror of https://github.com/kiwix/libkiwix.git
Make the limit of zim files per search configurable.
The default value is 0, which means no limit.
This commit is contained in:
parent
b74910b2af
commit
0081b4d8e7
|
@ -54,6 +54,7 @@ namespace kiwix
|
|||
void setAddress(const std::string& addr) { m_addr = addr; }
|
||||
void setPort(int port) { m_port = port; }
|
||||
void setNbThreads(int threads) { m_nbThreads = threads; }
|
||||
void setMultiZimSearchLimit(unsigned int limit) { m_multizimSearchLimit = limit; }
|
||||
void setIpConnectionLimit(int limit) { m_ipConnectionLimit = limit; }
|
||||
void setVerbose(bool verbose) { m_verbose = verbose; }
|
||||
void setIndexTemplateString(const std::string& indexTemplateString) { m_indexTemplateString = indexTemplateString; }
|
||||
|
@ -72,6 +73,7 @@ namespace kiwix
|
|||
std::string m_indexTemplateString = "";
|
||||
int m_port = 80;
|
||||
int m_nbThreads = 1;
|
||||
unsigned int m_multizimSearchLimit = 0;
|
||||
bool m_verbose = false;
|
||||
bool m_withTaskbar = true;
|
||||
bool m_withLibraryButton = true;
|
||||
|
|
|
@ -45,6 +45,7 @@ bool Server::start() {
|
|||
m_port,
|
||||
m_root,
|
||||
m_nbThreads,
|
||||
m_multizimSearchLimit,
|
||||
m_verbose,
|
||||
m_withTaskbar,
|
||||
m_withLibraryButton,
|
||||
|
|
|
@ -207,7 +207,7 @@ void checkBookNumber(const Library::BookIdSet& bookIds, size_t limit) {
|
|||
if (bookIds.empty()) {
|
||||
throw Error(nonParameterizedMessage("no-book-found"));
|
||||
}
|
||||
if (bookIds.size() > limit) {
|
||||
if (limit > 0 && bookIds.size() > limit) {
|
||||
throw Error(tooManyBooksMsg(bookIds.size(), limit));
|
||||
}
|
||||
}
|
||||
|
@ -269,7 +269,7 @@ Library::BookIdSet InternalServer::selectBooks(const RequestContext& request) co
|
|||
SearchInfo InternalServer::getSearchInfo(const RequestContext& request) const
|
||||
{
|
||||
auto bookIds = selectBooks(request);
|
||||
checkBookNumber(bookIds, 5);
|
||||
checkBookNumber(bookIds, m_multizimSearchLimit);
|
||||
auto pattern = request.get_optional_param<std::string>("pattern", "");
|
||||
GeoQuery geoQuery;
|
||||
|
||||
|
@ -332,6 +332,7 @@ InternalServer::InternalServer(Library* library,
|
|||
int port,
|
||||
std::string root,
|
||||
int nbThreads,
|
||||
unsigned int multizimSearchLimit,
|
||||
bool verbose,
|
||||
bool withTaskbar,
|
||||
bool withLibraryButton,
|
||||
|
@ -342,6 +343,7 @@ InternalServer::InternalServer(Library* library,
|
|||
m_port(port),
|
||||
m_root(normalizeRootUrl(root)),
|
||||
m_nbThreads(nbThreads),
|
||||
m_multizimSearchLimit(multizimSearchLimit),
|
||||
m_verbose(verbose),
|
||||
m_withTaskbar(withTaskbar),
|
||||
m_withLibraryButton(withLibraryButton),
|
||||
|
|
|
@ -101,6 +101,7 @@ class InternalServer {
|
|||
int port,
|
||||
std::string root,
|
||||
int nbThreads,
|
||||
unsigned int multizimSearchLimit,
|
||||
bool verbose,
|
||||
bool withTaskbar,
|
||||
bool withLibraryButton,
|
||||
|
@ -156,6 +157,7 @@ class InternalServer {
|
|||
int m_port;
|
||||
std::string m_root;
|
||||
int m_nbThreads;
|
||||
unsigned int m_multizimSearchLimit;
|
||||
std::atomic_bool m_verbose;
|
||||
bool m_withTaskbar;
|
||||
bool m_withLibraryButton;
|
||||
|
|
Loading…
Reference in New Issue