Skip to content

Commit 3377f9e

Browse files
authored
Merge pull request #666 from kiwix/implement_skip_option_2
kiwix-serve: Skip invalid ZIM files and continue startup #659
2 parents 7913b6a + 930c832 commit 3377f9e

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

src/man/kiwix-serve.1

+4
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ Override the welcome page with a custom HTML file.
8888
\fB-L N, --ipConnectionLimit=N\fR
8989
Max number of (concurrent) connections per IP (default: infinite, recommended: >= 6).
9090

91+
.TP
92+
\fB-k, --skipInvalid\fR
93+
Startup even when ZIM files are invalid (those will be skipped)
94+
9195
.TP
9296
\fB-v, --verbose\fR
9397
Print debug log to STDOUT.

src/server/kiwix-serve.cpp

+13-3
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ void usage()
7777
<< "\t-z, --nodatealiases\tCreate URL aliases for each content by removing the date" << std::endl
7878
<< "\t-c, --customIndex\tAdd path to custom index.html for welcome page" << std::endl
7979
<< "\t-L, --ipConnectionLimit\tMax number of (concurrent) connections per IP (default: infinite, recommended: >= 6)" << std::endl
80+
<< "\t-k, --skipInvalid\tStartup even when ZIM files are invalid (those will be skipped)" << std::endl
8081
<< std::endl
8182

8283
<< "Documentation:" << std::endl
@@ -217,6 +218,7 @@ int main(int argc, char** argv)
217218
unsigned int PPID = 0;
218219
int ipConnectionLimit = 0;
219220
int searchLimit = 0;
221+
bool skipInvalid = false;
220222

221223
static struct option long_options[]
222224
= {{"daemon", no_argument, 0, 'd'},
@@ -237,6 +239,7 @@ int main(int argc, char** argv)
237239
{"monitorLibrary", no_argument, 0, 'M'},
238240
{"ipConnectionLimit", required_argument, 0, 'L'},
239241
{"searchLimit", required_argument, 0, 's'},
242+
{"skipInvalid", no_argument, 0, 'k'},
240243
{0, 0, 0, 0}};
241244

242245
std::set<int> usedOptions;
@@ -307,6 +310,9 @@ int main(int argc, char** argv)
307310
case 's':
308311
searchLimit = atoi(optarg);
309312
break;
313+
case 'k':
314+
skipInvalid = true;
315+
break;
310316
case '?':
311317
usage();
312318
return 2;
@@ -348,9 +354,13 @@ int main(int argc, char** argv)
348354
std::vector<std::string>::iterator it;
349355
for (it = zimPathes.begin(); it != zimPathes.end(); it++) {
350356
if (!manager.addBookFromPath(*it, *it, "", false)) {
351-
std::cerr << "Unable to add the ZIM file '" << *it
352-
<< "' to the internal library." << std::endl;
353-
exit(1);
357+
if (skipInvalid) {
358+
std::cerr << "Skipping invalid '" << *it << "' ...continuing" << std::endl;
359+
} else {
360+
std::cerr << "Unable to add the ZIM file '" << *it
361+
<< "' to the internal library." << std::endl;
362+
exit(1);
363+
}
354364
}
355365
}
356366
}

0 commit comments

Comments
 (0)