From 456c77d8fd69d9df07bed13baa1d1e8316a9df6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Sch=C3=BCller?= Date: Sat, 20 Jan 2024 13:46:27 +0100 Subject: [PATCH 1/3] kiwix-serve: Skip broken ZIM files and continue startup --- src/server/kiwix-serve.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/server/kiwix-serve.cpp b/src/server/kiwix-serve.cpp index d50481b..cc882f8 100644 --- a/src/server/kiwix-serve.cpp +++ b/src/server/kiwix-serve.cpp @@ -77,6 +77,7 @@ void usage() << "\t-z, --nodatealiases\tCreate URL aliases for each content by removing the date" << std::endl << "\t-c, --customIndex\tAdd path to custom index.html for welcome page" << std::endl << "\t-L, --ipConnectionLimit\tMax number of (concurrent) connections per IP (default: infinite, recommended: >= 6)" << std::endl + << "\t-k, --skipBroken\tStartup the server even when ZIM files are broken (those will be skipped)" << std::endl << std::endl << "Documentation:" << std::endl @@ -217,6 +218,7 @@ int main(int argc, char** argv) unsigned int PPID = 0; int ipConnectionLimit = 0; int searchLimit = 0; + bool skipBroken = false; static struct option long_options[] = {{"daemon", no_argument, 0, 'd'}, @@ -237,6 +239,7 @@ int main(int argc, char** argv) {"monitorLibrary", no_argument, 0, 'M'}, {"ipConnectionLimit", required_argument, 0, 'L'}, {"searchLimit", required_argument, 0, 's'}, + {"skipBroken", no_argument, 0, 'k'}, {0, 0, 0, 0}}; std::set usedOptions; @@ -307,6 +310,9 @@ int main(int argc, char** argv) case 's': searchLimit = atoi(optarg); break; + case 'k': + skipBroken = true; + break; case '?': usage(); return 2; @@ -348,9 +354,13 @@ int main(int argc, char** argv) std::vector::iterator it; for (it = zimPathes.begin(); it != zimPathes.end(); it++) { if (!manager.addBookFromPath(*it, *it, "", false)) { - std::cerr << "Unable to add the ZIM file '" << *it - << "' to the internal library." << std::endl; - exit(1); + if ( skipBroken ) { + std::cerr << "Skipping broken '" << *it << "' ...continuing" << std::endl; + } else { + std::cerr << "Unable to add the ZIM file '" << *it + << "' to the internal library." << std::endl; + exit(1); + } } } } From a3239ea8bc9b24a3eb1b96e44b179de0d74c2332 Mon Sep 17 00:00:00 2001 From: Emmanuel Engelhart Date: Sun, 10 Mar 2024 16:50:34 +0100 Subject: [PATCH 2/3] Rename --skipBroken to --skipInvalid --- src/server/kiwix-serve.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/server/kiwix-serve.cpp b/src/server/kiwix-serve.cpp index cc882f8..4d968c9 100644 --- a/src/server/kiwix-serve.cpp +++ b/src/server/kiwix-serve.cpp @@ -77,7 +77,7 @@ void usage() << "\t-z, --nodatealiases\tCreate URL aliases for each content by removing the date" << std::endl << "\t-c, --customIndex\tAdd path to custom index.html for welcome page" << std::endl << "\t-L, --ipConnectionLimit\tMax number of (concurrent) connections per IP (default: infinite, recommended: >= 6)" << std::endl - << "\t-k, --skipBroken\tStartup the server even when ZIM files are broken (those will be skipped)" << std::endl + << "\t-k, --skipInvalid\tStartup even when ZIM files are invalid (those will be skipped)" << std::endl << std::endl << "Documentation:" << std::endl @@ -218,7 +218,7 @@ int main(int argc, char** argv) unsigned int PPID = 0; int ipConnectionLimit = 0; int searchLimit = 0; - bool skipBroken = false; + bool skipInvalid = false; static struct option long_options[] = {{"daemon", no_argument, 0, 'd'}, @@ -239,7 +239,7 @@ int main(int argc, char** argv) {"monitorLibrary", no_argument, 0, 'M'}, {"ipConnectionLimit", required_argument, 0, 'L'}, {"searchLimit", required_argument, 0, 's'}, - {"skipBroken", no_argument, 0, 'k'}, + {"skipInvalid", no_argument, 0, 'k'}, {0, 0, 0, 0}}; std::set usedOptions; @@ -311,7 +311,7 @@ int main(int argc, char** argv) searchLimit = atoi(optarg); break; case 'k': - skipBroken = true; + skipInvalid = true; break; case '?': usage(); @@ -354,8 +354,8 @@ int main(int argc, char** argv) std::vector::iterator it; for (it = zimPathes.begin(); it != zimPathes.end(); it++) { if (!manager.addBookFromPath(*it, *it, "", false)) { - if ( skipBroken ) { - std::cerr << "Skipping broken '" << *it << "' ...continuing" << std::endl; + if (skipInvalid) { + std::cerr << "Skipping invalid '" << *it << "' ...continuing" << std::endl; } else { std::cerr << "Unable to add the ZIM file '" << *it << "' to the internal library." << std::endl; From 930c8321ca7632cf85d0f945ff5aae922873fc7c Mon Sep 17 00:00:00 2001 From: Emmanuel Engelhart Date: Sun, 10 Mar 2024 16:53:15 +0100 Subject: [PATCH 3/3] Add --skipInvalid option to man page --- src/man/kiwix-serve.1 | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/man/kiwix-serve.1 b/src/man/kiwix-serve.1 index 064e530..69d86b4 100644 --- a/src/man/kiwix-serve.1 +++ b/src/man/kiwix-serve.1 @@ -88,6 +88,10 @@ Override the welcome page with a custom HTML file. \fB-L N, --ipConnectionLimit=N\fR Max number of (concurrent) connections per IP (default: infinite, recommended: >= 6). +.TP +\fB-k, --skipInvalid\fR +Startup even when ZIM files are invalid (those will be skipped) + .TP \fB-v, --verbose\fR Print debug log to STDOUT.