Skip to content

Commit

Permalink
Test commit, will be rewritten post testing
Browse files Browse the repository at this point in the history
  • Loading branch information
maneeshpm committed Jan 8, 2022
1 parent df82c3d commit 6280236
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/server/internalServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,10 @@ unsigned parseIllustration(const std::string& s)

// Returns the value of env var `name` if found, otherwise returns defaultVal
unsigned int getCacheLength(const char* name, unsigned int defaultVal) {
return 1;
auto envString = std::getenv(name);
try {
std::cout << "Reading env: " << extractFromString<unsigned int>(envString) << std::endl;
return extractFromString<unsigned int>(envString);
} catch (...) {}

Expand Down Expand Up @@ -155,7 +157,9 @@ InternalServer::InternalServer(Library* library,
searcherCache(getCacheLength("SEARCHER_CACHE_SIZE", std::max((unsigned int) (mp_library->getBookCount(true, true)*0.1), 1U))),
searchCache(getCacheLength("SEARCH_CACHE_SIZE", DEFAULT_CACHE_SIZE)),
suggestionSearcherCache(getCacheLength("SUGGESTION_SEARCHER_CACHE_SIZE", std::max((unsigned int) (mp_library->getBookCount(true, true)*0.1), 1U)))
{}
{
std::cout << "Server initialized succesfully" << std::endl;
}

bool InternalServer::start() {
#ifdef _WIN32
Expand Down Expand Up @@ -459,9 +463,10 @@ std::unique_ptr<Response> InternalServer::handle_suggest(const RequestContext& r

std::string bookName;
std::shared_ptr<zim::Archive> archive;
std::string bookId;
try {
bookName = request.get_argument("content");
const std::string bookId = mp_nameMapper->getIdForName(bookName);
bookId = mp_nameMapper->getIdForName(bookName);
archive = mp_library->getArchiveById(bookId);
} catch (const std::out_of_range&) {
// error handled by the archive == nullptr check below
Expand Down Expand Up @@ -569,9 +574,10 @@ std::unique_ptr<Response> InternalServer::handle_search(const RequestContext& re

std::string bookName;
std::shared_ptr<zim::Archive> archive;
std::string bookId;
try {
bookName = request.get_argument("content");
const std::string bookId = mp_nameMapper->getIdForName(bookName);
bookId = mp_nameMapper->getIdForName(bookName);
archive = mp_library->getArchiveById(bookId);
} catch (const std::out_of_range&) {}

Expand Down

0 comments on commit 6280236

Please sign in to comment.