diff options
author | Godin <mandrikov@gmail.com> | 2010-11-08 11:33:46 +0000 |
---|---|---|
committer | Godin <mandrikov@gmail.com> | 2010-11-08 11:33:46 +0000 |
commit | f6b610279f15ea90afed29deb0df4e5928e9d8c0 (patch) | |
tree | b1a90a00c06dc233a97a1352a69f59f74a4dcf84 /sonar-server/src/main/java | |
parent | 6e582ed6c46a23140460648d5496bbf759a44914 (diff) | |
download | sonarqube-f6b610279f15ea90afed29deb0df4e5928e9d8c0.tar.gz sonarqube-f6b610279f15ea90afed29deb0df4e5928e9d8c0.zip |
SONAR-1705: Do not create directory for embedded database if sonar home directory not exists
Diffstat (limited to 'sonar-server/src/main/java')
-rw-r--r-- | sonar-server/src/main/java/org/sonar/server/database/EmbeddedDatabase.java | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/sonar-server/src/main/java/org/sonar/server/database/EmbeddedDatabase.java b/sonar-server/src/main/java/org/sonar/server/database/EmbeddedDatabase.java index f1126ab529a..c9a5a7da3df 100644 --- a/sonar-server/src/main/java/org/sonar/server/database/EmbeddedDatabase.java +++ b/sonar-server/src/main/java/org/sonar/server/database/EmbeddedDatabase.java @@ -26,6 +26,7 @@ import org.sonar.api.CoreProperties; import org.sonar.api.database.DatabaseProperties; import org.sonar.api.utils.Logs; import org.sonar.api.utils.SonarException; +import org.sonar.server.platform.ServerStartException; import java.io.File; import java.io.FileOutputStream; @@ -62,7 +63,10 @@ public class EmbeddedDatabase { protected File autodetectDataDirectory(Configuration configuration) { String dirName = configuration.getString(DatabaseProperties.PROP_EMBEDDED_DATA_DIR); if (dirName == null) { - String sonarHome = configuration.getString(CoreProperties.SONAR_HOME); + File sonarHome = new File(configuration.getString(CoreProperties.SONAR_HOME)); + if ( !sonarHome.isDirectory() || !sonarHome.exists()) { + throw new ServerStartException("Sonar home directory does not exist"); + } return new File(sonarHome, "data"); } return new File(dirName); @@ -76,7 +80,7 @@ public class EmbeddedDatabase { if (dbHome.exists() && !dbHome.isDirectory()) { throw new SonarException("Database home " + dbHome.getPath() + " is not a directory"); } - if (!dbHome.exists()) { + if ( !dbHome.exists()) { dbHome.mkdirs(); } System.setProperty("derby.system.home", dbHome.getPath()); |