Fix crash with ZIM files without FT indexes

This commit is contained in:
kelson42 2016-10-02 18:29:49 +02:00
parent 2458c22e09
commit cd623ce358

View File

@ -572,20 +572,13 @@ int main(int argc, char **argv) {
}
} else {
std::vector<std::string>::iterator it;
for (it = zimPathes.begin(); it != zimPathes.end(); it++)
{
for (it = zimPathes.begin(); it != zimPathes.end(); it++) {
if (!libraryManager.addBookFromPath(*it, *it, "", false)) {
cerr << "Unable to add the ZIM file '" << *it << "' to the internal library." << endl;
exit(1);
}
}
if (!indexPath.empty()) {
try {
new kiwix::XapianSearcher(indexPath);
} catch (...) {
cerr << "Unable to open the search index '" << indexPath << "'." << endl;
}
libraryManager.setBookIndex(libraryManager.getBooksIds()[0], indexPath);
}
}
@ -618,17 +611,20 @@ int main(int argc, char **argv) {
/* Try to instanciate the zim index.
* If there is no specified indexPath, try to open the
* embedded index in the zim. */
if (indexPath.empty()) {
indexPath = zimPath;
if (indexPath.empty() && reader->hasFulltextIndex()) {
indexPath = zimPath;
}
try {
kiwix::Searcher *searcher = new kiwix::XapianSearcher(indexPath);
searcher->setProtocolPrefix("/");
searcher->setSearchProtocolPrefix("/search?");
searcher->setContentHumanReadableId(humanReadableId);
searchers[humanReadableId] = searcher;
} catch (...) {
cerr << "Unable to open the search index '" << indexPath << "'." << endl;
if (!indexPath.empty()) {
try {
kiwix::Searcher *searcher = new kiwix::XapianSearcher(indexPath);
searcher->setProtocolPrefix("/");
searcher->setSearchProtocolPrefix("/search?");
searcher->setContentHumanReadableId(humanReadableId);
searchers[humanReadableId] = searcher;
} catch (...) {
cerr << "Unable to open the search index '" << indexPath << "'." << endl;
}
}
}
}