+ 2nd regression fix

This commit is contained in:
kelson42 2011-04-19 06:29:19 +00:00
parent 0ae076b5ad
commit 417749a3fc

View File

@ -416,33 +416,6 @@ int main(int argc, char **argv) {
/* Instanciate the ZIM index (if necessary) */ /* Instanciate the ZIM index (if necessary) */
if (indexPath != "") { if (indexPath != "") {
/* Change the current dir to binary dir */
/* Non portable linux solution */
readlink("/proc/self/exe", rootPath, PATH_MAX);
chdir(dirname(rootPath));
/* Try to load the result template */
try {
fstream templateStream;
templateStream.open("../share/kiwix/static/results.tmpl", ifstream::in);
if (templateStream.fail()) {
templateStream.open("../../static/results.tmpl", ifstream::in);
if (templateStream.fail()) {
throw "Unable to find a result template file.";
} else {
realpath("../../static/results.tmpl", rootPath);
searcher->setResultTemplatePath(rootPath);
}
} else {
realpath("../share/kiwix/static/results.tmpl", rootPath);
searcher->setResultTemplatePath(rootPath);
}
} catch (...) {
cerr << "Unable to open the result template file." << endl;
exit(1);
}
/* Try with the XapianSearcher */ /* Try with the XapianSearcher */
try { try {
@ -463,9 +436,40 @@ int main(int argc, char **argv) {
} }
} }
/* searcher configuration */ /* searcher configuration */
searcher->setProtocolPrefix("/"); if (hasSearchIndex) {
searcher->setSearchProtocolPrefix("/search?");
/* Change the current dir to binary dir */
/* Non portable linux solution */
readlink("/proc/self/exe", rootPath, PATH_MAX);
chdir(dirname(rootPath));
/* Try to load the result template */
try {
fstream templateStream;
templateStream.open("../share/kiwix/static/results.tmpl", ifstream::in);
if (templateStream.fail()) {
templateStream.open("../../static/results.tmpl", ifstream::in);
if (templateStream.fail()) {
throw "Unable to find a result template file.";
} else {
realpath("../../static/results.tmpl", rootPath);
searcher->setResultTemplatePath(rootPath);
}
} else {
realpath("../share/kiwix/static/results.tmpl", rootPath);
searcher->setResultTemplatePath(rootPath);
}
} catch (...) {
cerr << "Unable to open the result template file." << endl;
exit(1);
}
searcher->setProtocolPrefix("/");
searcher->setSearchProtocolPrefix("/search?");
}
} else { } else {
hasSearchIndex = false; hasSearchIndex = false;