Initialize local database directory during startup

This commit is contained in:
Kai S. K. Engelbart 2020-09-20 09:08:09 +02:00
parent fd21c5789f
commit a8aa1c9ea7
Signed by: kske
GPG Key ID: 8BEB13EC5DF7EF13
1 changed files with 5 additions and 2 deletions

View File

@ -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");