[serve] Trust the library by default.

Now `kiwix-serve` trust the information in the library.xml.
We do not open all zim file at startup and so kiwix-serve starts faster.

Need kiwix/kiwix-lib#314
Fix #319
This commit is contained in:
Matthieu Gautier 2020-01-30 17:58:41 +01:00
parent 2fd393285f
commit e9676ae66f

View File

@ -66,6 +66,7 @@ void usage()
<< "\t-v, --verbose\t\tprint debug log to STDOUT" << std::endl << "\t-v, --verbose\t\tprint debug log to STDOUT" << std::endl
<< "\t-V, --version\t\tprint software version" << std::endl << "\t-V, --version\t\tprint software version" << std::endl
<< "\t-z, --nodatealiases\tcreate URL aliases for each content by removing the date" << std::endl << "\t-z, --nodatealiases\tcreate URL aliases for each content by removing the date" << std::endl
<< "\t--donottrustlibrary\tRead the metadata from the zim file instead of trusting the library." << std::endl
<< std::endl << std::endl
<< "Documentation:" << std::endl << "Documentation:" << std::endl
@ -90,6 +91,7 @@ int main(int argc, char** argv)
bool noSearchBarFlag = false; bool noSearchBarFlag = false;
bool noDateAliasesFlag = false; bool noDateAliasesFlag = false;
bool isVerboseFlag = false; bool isVerboseFlag = false;
bool trustlibrary = true;
string PPIDString; string PPIDString;
unsigned int PPID = 0; unsigned int PPID = 0;
@ -106,6 +108,7 @@ int main(int argc, char** argv)
{"address", required_argument, 0, 'i'}, {"address", required_argument, 0, 'i'},
{"threads", required_argument, 0, 't'}, {"threads", required_argument, 0, 't'},
{"urlRootLocation", required_argument, 0, 'r'}, {"urlRootLocation", required_argument, 0, 'r'},
{"donottrustlibrary", no_argument, 0, 'T'},
{0, 0, 0, 0}}; {0, 0, 0, 0}};
/* Argument parsing */ /* Argument parsing */
@ -137,6 +140,8 @@ int main(int argc, char** argv)
case 'm': case 'm':
noLibraryButtonFlag = true; noLibraryButtonFlag = true;
break; break;
case 'T':
trustlibrary = false;
case 'p': case 'p':
serverPort = atoi(optarg); serverPort = atoi(optarg);
break; break;
@ -188,7 +193,7 @@ int main(int argc, char** argv)
= isRelativePath(*itr) = isRelativePath(*itr)
? computeAbsolutePath(getCurrentDirectory(), *itr) ? computeAbsolutePath(getCurrentDirectory(), *itr)
: *itr; : *itr;
retVal = manager.readFile(libraryPath, true); retVal = manager.readFile(libraryPath, true, trustlibrary);
} catch (...) { } catch (...) {
retVal = false; retVal = false;
} }