3
0
Fork 0

Fix crash with ZIM files without FT indexes

small_fixes
kelson42 10 years ago
parent 2458c22e09
commit cd623ce358

@ -572,20 +572,13 @@ int main(int argc, char **argv) {
} }
} else { } else {
std::vector<std::string>::iterator it; 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)) { if (!libraryManager.addBookFromPath(*it, *it, "", false)) {
cerr << "Unable to add the ZIM file '" << *it << "' to the internal library." << endl; cerr << "Unable to add the ZIM file '" << *it << "' to the internal library." << endl;
exit(1); exit(1);
} }
} }
if (!indexPath.empty()) { if (!indexPath.empty()) {
try {
new kiwix::XapianSearcher(indexPath);
} catch (...) {
cerr << "Unable to open the search index '" << indexPath << "'." << endl;
}
libraryManager.setBookIndex(libraryManager.getBooksIds()[0], indexPath); libraryManager.setBookIndex(libraryManager.getBooksIds()[0], indexPath);
} }
} }
@ -618,9 +611,11 @@ int main(int argc, char **argv) {
/* Try to instanciate the zim index. /* Try to instanciate the zim index.
* If there is no specified indexPath, try to open the * If there is no specified indexPath, try to open the
* embedded index in the zim. */ * embedded index in the zim. */
if (indexPath.empty()) { if (indexPath.empty() && reader->hasFulltextIndex()) {
indexPath = zimPath; indexPath = zimPath;
} }
if (!indexPath.empty()) {
try { try {
kiwix::Searcher *searcher = new kiwix::XapianSearcher(indexPath); kiwix::Searcher *searcher = new kiwix::XapianSearcher(indexPath);
searcher->setProtocolPrefix("/"); searcher->setProtocolPrefix("/");
@ -633,6 +628,7 @@ int main(int argc, char **argv) {
} }
} }
} }
}
/* Compute the Welcome HTML */ /* Compute the Welcome HTML */
string welcomeBooksHtml; string welcomeBooksHtml;

Loading…
Cancel
Save