KEYCLOAK-19711 Change Locations of h2-db files and gzip files

This commit is contained in:
Dominik Guhr 2021-11-01 13:16:25 +01:00 committed by Pedro Igor
parent adda65deb6
commit 29b1aec4b5
4 changed files with 10 additions and 4 deletions

View file

@ -39,6 +39,7 @@ public final class Environment {
public static final String CLI_ARGS = "kc.config.args";
public static final String PROFILE ="kc.profile";
public static final String ENV_PROFILE ="KC_PROFILE";
public static final String DATA_PATH = "/data";
private Environment() {}
@ -60,6 +61,10 @@ public final class Environment {
return null;
}
public static String getDataDir() {
return getHomeDir() + DATA_PATH;
}
public static Path getProvidersPath() {
Path homePath = Environment.getHomePath();

View file

@ -148,7 +148,8 @@ public class QuarkusPlatform implements PlatformProvider {
throw new RuntimeException("It was not possible to create temporary directory keycloak-quarkus-tmp", ioex);
}
} else {
tmpDir = new File(homeDir, "tmp");
String dataDir = Environment.getDataDir();
tmpDir = new File(dataDir, "tmp");
tmpDir.mkdir();
}

View file

@ -94,7 +94,7 @@ public final class Database {
public String apply(String alias) {
if ("h2-file".equalsIgnoreCase(alias)) {
return "jdbc:h2:file:${kc.home.dir:${kc.db.url.path:~}}" + File.separator + "${kc.data.dir:data}"
+ File.separator + "keycloakdb${kc.db.url.properties:;;AUTO_SERVER=TRUE}";
+ File.separator + "h2" + File.separator + "keycloakdb${kc.db.url.properties:;;AUTO_SERVER=TRUE}";
}
return "jdbc:h2:mem:keycloakdb${kc.db.url.properties:}";
}

View file

@ -224,7 +224,7 @@ public class ConfigurationTest {
System.setProperty(CLI_ARGS, "--db=h2-file");
SmallRyeConfig config = createConfig();
assertEquals(QuarkusH2Dialect.class.getName(), config.getConfigValue("quarkus.hibernate-orm.dialect").getValue());
assertEquals("jdbc:h2:file:~/data/keycloakdb;;AUTO_SERVER=TRUE", config.getConfigValue("quarkus.datasource.jdbc.url").getValue());
assertEquals("jdbc:h2:file:~/data/h2/keycloakdb;;AUTO_SERVER=TRUE", config.getConfigValue("quarkus.datasource.jdbc.url").getValue());
System.setProperty(CLI_ARGS, "--db=h2-mem");
config = createConfig();
@ -250,7 +250,7 @@ public class ConfigurationTest {
System.setProperty(CLI_ARGS, "--db=h2-file");
SmallRyeConfig config = createConfig();
assertEquals(QuarkusH2Dialect.class.getName(), config.getConfigValue("quarkus.hibernate-orm.dialect").getValue());
assertEquals("jdbc:h2:file:test-dir" + File.separator + "data" + File.separator + "keycloakdb;;test=test;test1=test1", config.getConfigValue("quarkus.datasource.jdbc.url").getValue());
assertEquals("jdbc:h2:file:test-dir" + File.separator + "data" + File.separator + "h2" + File.separator + "keycloakdb;;test=test;test1=test1", config.getConfigValue("quarkus.datasource.jdbc.url").getValue());
System.setProperty("kc.db.url.properties", "?test=test&test1=test1");
System.setProperty(CLI_ARGS, "--db=mariadb");