Skip to content

Commit

Permalink
fixup! Retrieve Searcher and Search from LRU Cache
Browse files Browse the repository at this point in the history
  • Loading branch information
maneeshpm committed Jan 9, 2022
1 parent df82c3d commit 00af73c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/server/internalServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,11 @@ 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) {
auto envString = std::getenv(name);
try {
const char* envString = std::getenv(name);
if (envString == nullptr) {
throw std::runtime_error("Environment variable not set");
}
return extractFromString<unsigned int>(envString);
} catch (...) {}

Expand Down Expand Up @@ -567,11 +570,11 @@ std::unique_ptr<Response> InternalServer::handle_search(const RequestContext& re
} catch(const std::out_of_range&) {}
catch(const std::invalid_argument&) {}

std::string bookName;
std::string bookName, bookId;
std::shared_ptr<zim::Archive> archive;
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 00af73c

Please sign in to comment.