use of org.apache.jackrabbit.oak.segment.SegmentVersion in project jackrabbit-oak by apache.
the class SegmentTarUtils method checkFileStoreVersionOrFail.
private static File checkFileStoreVersionOrFail(String path, boolean force) throws IOException, InvalidFileStoreVersionException {
File directory = new File(path);
if (!directory.exists()) {
return directory;
}
ReadOnlyFileStore store = openReadOnlyFileStore(directory, false);
try {
SegmentVersion segmentVersion = getSegmentVersion(store);
if (segmentVersion != LATEST_VERSION) {
if (force) {
System.out.printf("Segment version mismatch. Found %s, expected %s. Forcing execution.\n", segmentVersion, LATEST_VERSION);
} else {
throw new RuntimeException(String.format("Segment version mismatch. Found %s, expected %s. Aborting.", segmentVersion, LATEST_VERSION));
}
}
} finally {
store.close();
}
return directory;
}
Aggregations