Skip to content

require -R for the --indexCheck #4218

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ public final class Indexer {

private static final Indexer indexer = new Indexer();
private static Configuration cfg = null;
private static boolean gotReadonlyConfiguration = false;
private static IndexCheck.IndexCheckMode indexCheckMode = IndexCheck.IndexCheckMode.NO_CHECK;
private static boolean runIndex = true;
private static boolean reduceSegmentCount = false;
Expand Down Expand Up @@ -265,7 +266,7 @@ public static void main(String[] argv) {
// Check index(es). Exit with return code upon failure.
if (indexCheckMode.ordinal() > IndexCheck.IndexCheckMode.NO_CHECK.ordinal()) {
if (cfg.getDataRoot() == null || cfg.getDataRoot().isEmpty()) {
System.err.println("Need data root in configuration for index check (use -R)");
System.err.println("Empty data root in configuration");
System.exit(1);
}

Expand Down Expand Up @@ -485,6 +486,7 @@ public static String[] parseOptions(String[] argv) throws ParseException {
parser.on("-R configPath").execute(cfgFile -> {
try {
cfg = Configuration.read(new File((String) cfgFile));
gotReadonlyConfiguration = true;
} catch (IOException e) {
if (!preHelp) {
die(e.getMessage());
Expand Down Expand Up @@ -575,9 +577,15 @@ public static String[] parseOptions(String[] argv) throws ParseException {
"Check index, exit with 0 on success,",
"with 1 on failure.",
"With no mode specified, performs basic index check.",
"Has to be used with the -R option to read the configuration ",
"saved by previous indexer run via the -W option.",
"Selectable modes (performs given test on top of the basic check):",
" documents - checks duplicate documents in the index"
).execute(v -> {
if (!gotReadonlyConfiguration) {
die("option --checkIndex requires -R");
}

indexCheckMode = IndexCheck.IndexCheckMode.VERSION;
String mode = (String) v;
if (mode != null && !mode.isEmpty()) {
Expand Down