From a8aa1c9ea741bd93c94e0b5449bbb07f12dafbf2 Mon Sep 17 00:00:00 2001 From: kske Date: Sun, 20 Sep 2020 09:08:09 +0200 Subject: [PATCH] Initialize local database directory during startup --- client/src/main/java/envoy/client/data/LocalDB.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/client/src/main/java/envoy/client/data/LocalDB.java b/client/src/main/java/envoy/client/data/LocalDB.java index 1756c30..f058c10 100644 --- a/client/src/main/java/envoy/client/data/LocalDB.java +++ b/client/src/main/java/envoy/client/data/LocalDB.java @@ -53,10 +53,13 @@ public final class LocalDB implements EventListener { this.dbDir = dbDir; EventBus.getInstance().registerListener(this); - // Test if the database directory is actually a directory - if (dbDir.exists() && !dbDir.isDirectory()) + // Ensure that the database directory exists + if (!dbDir.exists()) { + dbDir.mkdirs(); + } else if (!dbDir.isDirectory()) throw new IOException(String.format("LocalDBDir '%s' is not a directory!", dbDir.getAbsolutePath())); + // Initialize global files idGeneratorFile = new File(dbDir, "id_gen.db"); lastLoginFile = new File(dbDir, "last_login.db");