Remove logic from DatabaseConfig.

This commit is contained in:
akwizgran
2018-07-26 15:57:37 +01:00
parent f9495b49d6
commit 6f6ba38de1
8 changed files with 7 additions and 54 deletions

View File

@@ -50,8 +50,7 @@ class H2Database extends JdbcDatabase {
public boolean open(SecretKey key, @Nullable MigrationListener listener)
throws DbException {
this.key = key;
boolean reopen = config.databaseExists();
if (!reopen) config.getDatabaseDirectory().mkdirs();
boolean reopen = !config.getDatabaseDirectory().mkdirs();
super.open("org.h2.Driver", reopen, key, listener);
return reopen;
}

View File

@@ -52,8 +52,7 @@ class HyperSqlDatabase extends JdbcDatabase {
public boolean open(SecretKey key, @Nullable MigrationListener listener)
throws DbException {
this.key = key;
boolean reopen = config.databaseExists();
if (!reopen) config.getDatabaseDirectory().mkdirs();
boolean reopen = !config.getDatabaseDirectory().mkdirs();
super.open("org.hsqldb.jdbc.JDBCDriver", reopen, key, listener);
return reopen;
}

View File

@@ -17,13 +17,6 @@ public class TestDatabaseConfig implements DatabaseConfig {
this.maxSize = maxSize;
}
@Override
public boolean databaseExists() {
if (!dbDir.isDirectory()) return false;
File[] files = dbDir.listFiles();
return files != null && files.length > 0;
}
@Override
public File getDatabaseDirectory() {
return dbDir;