Skip to content

Commit 64bb287

Browse files
ddamkeddamke
authored andcommitted
checks imported h2 version is 1 oder newer
1 parent 019ae92 commit 64bb287

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

src/main/java/de/doubleslash/keeptime/view/SettingsController.java

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -365,12 +365,12 @@ private void initImportButton() {
365365
confirmationAlert.setHeaderText("Do you want to Override current Data ?");
366366
confirmationAlert.getDialogPane()
367367
.setContent(new Label(
368-
"""
369-
Import previously exported .sql file. This will overwrite the currently used database contents - all current data will be lost!
370-
371-
If you do not have a .sql file yet you need to open the previous version of KeepTime and in the settings dialog press "Export".
372-
373-
You will need to restart the application after this action. If you proceed you need to select the previous exported .sql file.\
368+
"""
369+
Import previously exported .sql file. This will overwrite the currently used database contents - all current data will be lost!
370+
371+
If you do not have a .sql file yet you need to open the previous version of KeepTime and in the settings dialog press "Export".
372+
373+
You will need to restart the application after this action. If you proceed you need to select the previous exported .sql file.\
374374
"""));
375375
confirmationAlert.showAndWait();
376376

@@ -391,10 +391,13 @@ private void initImportButton() {
391391
final String url = applicationProperties.getSpringDataSourceUrl();
392392
final String username = applicationProperties.getSpringDataSourceUserName();
393393
final String password = applicationProperties.getSpringDataSourcePassword();
394-
// TODO: add an option at the next release to make the "FROM_1X flag" configurable. E.g. if we upgrade (in
395-
// the release after) from H2 version 2.x to 2.x we must not set the "FROM_1X flag".
396-
new RunScript().runTool("-url", url, "-user", username, "-password", password, "-script", file.toString(),
397-
"-options", "FROM_1X");
394+
395+
if (file.getName().contains("version-1")) {
396+
new RunScript().runTool("-url", url, "-user", username, "-password", password, "-script", file.toString(),
397+
"-options", "FROM_1X");
398+
}else {
399+
new RunScript().runTool("-url", url, "-user", username, "-password", password, "-script", file.toString());
400+
}
398401

399402
Alert informationDialog = new Alert(AlertType.INFORMATION);
400403

@@ -404,9 +407,9 @@ private void initImportButton() {
404407
informationDialog.setTitle("Import done");
405408
informationDialog.setHeaderText("The data was imported.");
406409
informationDialog.getDialogPane()
407-
.setContent(new Label("""
408-
KeepTime will now be CLOSED!
409-
You have to RESTART it again to see the changes\
410+
.setContent(new Label("""
411+
KeepTime will now be CLOSED!
412+
You have to RESTART it again to see the changes\
410413
"""));
411414
informationDialog.showAndWait();
412415
Platform.exit();
@@ -525,8 +528,8 @@ private void showLicense(final Licenses license) {
525528
final Alert alert = new Alert(AlertType.ERROR);
526529
alert.setTitle("Ooops");
527530
alert.setHeaderText("Could not find the license file");
528-
alert.setContentText(
529-
"We could not find the license file at \"%s\". Did you remove it?%nPlease redownload or visit \"%s\".".formatted(
531+
alert.setContentText(
532+
"We could not find the license file at \"%s\". Did you remove it?%nPlease redownload or visit \"%s\".".formatted(
530533
license.getPath(), license.getUrl()));
531534

532535
alert.getDialogPane().setMinHeight(Region.USE_PREF_SIZE);

0 commit comments

Comments
 (0)