diff --git oak-doc/src/site/markdown/nodestore/segment/overview.md oak-doc/src/site/markdown/nodestore/segment/overview.md index ecb6526..5594b19 100644 --- oak-doc/src/site/markdown/nodestore/segment/overview.md +++ oak-doc/src/site/markdown/nodestore/segment/overview.md @@ -548,9 +548,9 @@ If not specified, progress information messages will be disabled. If `SECS` equals `0`, every progress information message is printed. If the `--bin` option is specified, the tool will scan the content of binary properties, up to the specified length `LENGTH`. -The default value for `LENGTH` is `0`, effectively disabling the traversal of binary properties. +If not specified, the full traversal of binary properties is enabled. If `LENGTH` is set to a value greater than `0`, only the initial `LENGTH` bytes of binary properties are traversed. -If `LENGTH` is set to `-1`, binary properties are fully traversed. +If `LENGTH` is set to `0`, the traversal is disabled. The `--bin` property has no effect on binary properties stored in an external Blob Store. ### Compact diff --git oak-run/src/main/java/org/apache/jackrabbit/oak/run/CheckCommand.java oak-run/src/main/java/org/apache/jackrabbit/oak/run/CheckCommand.java index 62523dc..688a92d 100644 --- oak-run/src/main/java/org/apache/jackrabbit/oak/run/CheckCommand.java +++ oak-run/src/main/java/org/apache/jackrabbit/oak/run/CheckCommand.java @@ -20,6 +20,7 @@ package org.apache.jackrabbit.oak.run; import static org.apache.jackrabbit.oak.plugins.segment.FileStoreHelper.isValidFileStoreOrFail; import java.io.File; +import java.io.IOException; import joptsimple.ArgumentAcceptingOptionSpec; import joptsimple.OptionParser; @@ -40,23 +41,30 @@ class CheckCommand implements Command { "notify", "number of seconds between progress notifications") .withRequiredArg().ofType(Long.class).defaultsTo(Long.MAX_VALUE); ArgumentAcceptingOptionSpec bin = parser.accepts( - "bin", "read the n first bytes from binary properties. -1 for all bytes.") - .withOptionalArg().ofType(Long.class).defaultsTo(0L); + "bin", "read the first n bytes from binary properties.") + .withRequiredArg().ofType(Long.class); OptionSpec segment = parser.accepts("segment", "Use oak-segment instead of oak-segment-tar"); OptionSet options = parser.parse(args); if (options.nonOptionArguments().size() != 1) { - System.err.println("usage: check path/to/segmentstore "); - parser.printHelpOn(System.err); - System.exit(1); + printUsage(parser); } File dir = isValidFileStoreOrFail(new File(options.nonOptionArguments().get(0).toString())); String journalFileName = journal.value(options); boolean fullTraversal = options.has(deep); long debugLevel = notify.value(options); - long binLen = bin.value(options); + + long binLen = -1L; + + if (options.has(bin)) { + binLen = bin.value(options); + + if (binLen < 0) { + printUsage(parser, "The value for --bin option must be a positive number!"); + } + } if (options.has(segment)) { SegmentUtils.check(dir, journalFileName, fullTraversal, debugLevel, binLen); @@ -65,4 +73,14 @@ class CheckCommand implements Command { } } + private void printUsage(OptionParser parser, String... messages) throws IOException { + for (String message : messages) { + System.err.println(message); + } + + System.err.println("usage: check path/to/segmentstore "); + parser.printHelpOn(System.err); + System.exit(1); + } + }