Skip to content

Commit

Permalink
Fixes bug where database was not initialized correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
Erik Følstad authored and Erik Følstad committed Aug 23, 2020
1 parent 3ba3df9 commit 57ac2cb
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>com.erikmafo</groupId>
<artifactId>bigtableviewer</artifactId>
<version>0.1.8</version>
<version>0.1.9</version>
<packaging>jar</packaging>
<name>bigtableviewer</name>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
*/
public class MainController {

@FXML
private MenuBarController menuBarController;

@FXML
private QueryBoxController queryBoxController;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ public class MenuBarController {
private MenuBar menuBar;

@Inject
public MenuBarController(LoadCredentialsPathService loadCredentialsPathService, SaveCredentialsPathService saveCredentialsPathService) {
public MenuBarController(
LoadCredentialsPathService loadCredentialsPathService,
SaveCredentialsPathService saveCredentialsPathService) {
this.loadCredentialsPathService = loadCredentialsPathService;
this.saveCredentialsPathService = saveCredentialsPathService;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import org.mapdb.*;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.*;
import java.util.concurrent.ConcurrentMap;
import java.util.stream.Collectors;
Expand All @@ -29,11 +31,18 @@ public static AppDataStorage createInMemory() {
}

public static AppDataStorage createInstance() {
var path = AppDataUtil
.getStorageFolder()
.resolve("database");
var storageDir = AppDataUtil.getStorageFolder();
if (!Files.exists(storageDir)) {
try {
Files.createDirectories(storageDir);
} catch (IOException e) {
return createInMemory();
}
}

var dbFile = storageDir.resolve("database").toFile();
var database = DBMaker
.fileDB(path.toFile())
.fileDB(dbFile)
.transactionEnable()
.closeOnJvmShutdown()
.make();
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/fxml/main.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
styleClass="pane-view">
<top>
<VBox>
<fx:include source="bigtable_menu_bar.fxml" fx:id="menuBar"/>
<fx:include fx:id="menuBar" source="bigtable_menu_bar.fxml"/>
</VBox>
</top>
<left>
Expand Down

0 comments on commit 57ac2cb

Please sign in to comment.