Skip to content
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

additional safety checks for config version #716

Merged
merged 3 commits into from
Jun 26, 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
12 changes: 7 additions & 5 deletions src/main/java/network/brightspots/rcv/TabulatorSession.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,20 @@ class TabulatorSession {
// here also
private static void checkConfigVersionMatchesApp(ContestConfig config) {
String version = config.getRawConfig().tabulatorVersion;

if (!version.equals(ContestConfig.AUTOMATED_TEST_VERSION)) {
//noinspection StatementWithEmptyBody
if (ContestConfigMigration.isConfigVersionNewerThanAppVersion(version)) {
// It will log a severe message already, so no need to add one here.
} else if (ContestConfigMigration.isConfigVersionOlderThanAppVersion(version)) {
// Below already logs a severe message, so no need to check and add another one
boolean isConfigVersionNewerThanAppVersion =
ContestConfigMigration.isConfigVersionNewerThanAppVersion(version);
if (!isConfigVersionNewerThanAppVersion
&& ContestConfigMigration.isConfigVersionOlderThanAppVersion(version)) {
Logger.severe(
"Can't use a config with older version %s in newer version %s of the app! To "
+ "automatically migrate the config to the newer version, load it in the graphical "
+ "version of the app (i.e. don't use the -cli flag when starting the tabulator).",
version, Main.APP_VERSION);
}
// No need to throw errors for these, because they'll be caught by validateTabulatorVersion()
// during validation
}
}

Expand Down