From b9e19d69b9b9f7a09473b32cd825817dd7105bc6 Mon Sep 17 00:00:00 2001 From: kske Date: Wed, 23 Sep 2020 16:00:53 +0200 Subject: [PATCH 1/2] Merge Local Database and Home Directory (#44) Merge local database and home directory Fixes #43 Reviewed-on: https://git.kske.dev/zdm/envoy/pulls/44 Reviewed-by: delvh --- client/src/main/java/envoy/client/data/ClientConfig.java | 9 --------- client/src/main/java/envoy/client/ui/Startup.java | 5 ++--- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/client/src/main/java/envoy/client/data/ClientConfig.java b/client/src/main/java/envoy/client/data/ClientConfig.java index f0789e2..613b970 100644 --- a/client/src/main/java/envoy/client/data/ClientConfig.java +++ b/client/src/main/java/envoy/client/data/ClientConfig.java @@ -2,8 +2,6 @@ package envoy.client.data; import static java.util.function.Function.identity; -import java.io.File; - import envoy.data.Config; /** @@ -34,7 +32,6 @@ public final class ClientConfig extends Config { super(".envoy"); put("server", "s", identity()); put("port", "p", Integer::parseInt); - put("localDB", "db", File::new); put("localDBSaveInterval", "db-si", Integer::parseInt); } @@ -50,12 +47,6 @@ public final class ClientConfig extends Config { */ public Integer getPort() { return (Integer) items.get("port").get(); } - /** - * @return the local database specific to the client user - * @since Envoy Client v0.1-alpha - */ - public File getLocalDB() { return (File) items.get("localDB").get(); } - /** * @return the amount of minutes after which the local database should be saved * @since Envoy Client v0.2-beta diff --git a/client/src/main/java/envoy/client/ui/Startup.java b/client/src/main/java/envoy/client/ui/Startup.java index 012cc00..448a764 100644 --- a/client/src/main/java/envoy/client/ui/Startup.java +++ b/client/src/main/java/envoy/client/ui/Startup.java @@ -70,9 +70,8 @@ public final class Startup extends Application { // Initialize the local database try { - final var localDBDir = new File(config.getHomeDirectory(), config.getLocalDB().getPath()); - logger.info("Initializing LocalDB at " + localDBDir); - localDB = new LocalDB(localDBDir); + logger.info("Initializing LocalDB at " + config.getHomeDirectory()); + localDB = new LocalDB(config.getHomeDirectory()); } catch (IOException | EnvoyException e) { logger.log(Level.SEVERE, "Could not initialize local database: ", e); new Alert(AlertType.ERROR, "Could not initialize local database!\n" + e).showAndWait(); From 758e52e030938ba256f8e0f2754bf734c0988864 Mon Sep 17 00:00:00 2001 From: kske Date: Wed, 23 Sep 2020 16:23:42 +0200 Subject: [PATCH 2/2] Store the Local Database Inside a Server-Specific Subdirectory (#45) Store the local database inside a server-specific subdirectory Reviewed-on: https://git.kske.dev/zdm/envoy/pulls/45 Reviewed-by: delvh --- client/src/main/java/envoy/client/ui/Startup.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/client/src/main/java/envoy/client/ui/Startup.java b/client/src/main/java/envoy/client/ui/Startup.java index 448a764..2e6b5d2 100644 --- a/client/src/main/java/envoy/client/ui/Startup.java +++ b/client/src/main/java/envoy/client/ui/Startup.java @@ -70,8 +70,9 @@ public final class Startup extends Application { // Initialize the local database try { - logger.info("Initializing LocalDB at " + config.getHomeDirectory()); - localDB = new LocalDB(config.getHomeDirectory()); + var localDBFile = new File(config.getHomeDirectory(), config.getServer()); + logger.info("Initializing LocalDB at " + localDBFile); + localDB = new LocalDB(localDBFile); } catch (IOException | EnvoyException e) { logger.log(Level.SEVERE, "Could not initialize local database: ", e); new Alert(AlertType.ERROR, "Could not initialize local database!\n" + e).showAndWait();