aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-application/src/main/java
diff options
context:
space:
mode:
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>2016-02-04 17:21:40 +0100
committerSébastien Lesaint <sebastien.lesaint@sonarsource.com>2016-02-05 17:02:10 +0100
commit035f7bdfe2b9bf7992ccd4fed456de98d007b305 (patch)
tree61300c3e7d11c30c32884b50853278f6320fc34e /sonar-application/src/main/java
parent4741428f2476010bfbdb36650f4f5de194410c16 (diff)
downloadsonarqube-035f7bdfe2b9bf7992ccd4fed456de98d007b305.tar.gz
sonarqube-035f7bdfe2b9bf7992ccd4fed456de98d007b305.zip
SONAR-7154 never delete temp dir, only delete its content if exists
Diffstat (limited to 'sonar-application/src/main/java')
-rw-r--r--sonar-application/src/main/java/org/sonar/application/AppFileSystem.java17
1 files changed, 8 insertions, 9 deletions
diff --git a/sonar-application/src/main/java/org/sonar/application/AppFileSystem.java b/sonar-application/src/main/java/org/sonar/application/AppFileSystem.java
index 32f563737b2..b71ba43faae 100644
--- a/sonar-application/src/main/java/org/sonar/application/AppFileSystem.java
+++ b/sonar-application/src/main/java/org/sonar/application/AppFileSystem.java
@@ -26,7 +26,7 @@ import org.slf4j.LoggerFactory;
import org.sonar.process.Props;
import org.sonar.process.monitor.FileSystem;
-import static org.apache.commons.io.FileUtils.deleteQuietly;
+import static org.apache.commons.io.FileUtils.cleanDirectory;
import static org.apache.commons.io.FileUtils.forceMkdir;
import static org.sonar.process.ProcessProperties.PATH_DATA;
import static org.sonar.process.ProcessProperties.PATH_HOME;
@@ -67,9 +67,9 @@ public class AppFileSystem implements FileSystem {
if (!initialized) {
throw new IllegalStateException("method verifyProps must be called first");
}
- ensureDirectoryExists(props, PATH_DATA);
- ensureDirectoryExists(props, PATH_WEB);
- ensureDirectoryExists(props, PATH_LOGS);
+ createDirectory(props, PATH_DATA);
+ createDirectory(props, PATH_WEB);
+ createDirectory(props, PATH_LOGS);
createOrCleanDirectory(props, PATH_TEMP);
}
@@ -89,7 +89,7 @@ public class AppFileSystem implements FileSystem {
return d;
}
- private static boolean ensureDirectoryExists(Props props, String propKey) throws IOException {
+ private static boolean createDirectory(Props props, String propKey) throws IOException {
File dir = props.nonNullValueAsFile(propKey);
if (dir.exists()) {
ensureIsNotAFile(propKey, dir);
@@ -111,10 +111,9 @@ public class AppFileSystem implements FileSystem {
private static void createOrCleanDirectory(Props props, String propKey) throws IOException {
File dir = props.nonNullValueAsFile(propKey);
- LOG.info("Deleting and/or creating temp directory {}", dir.getAbsolutePath());
- if (!ensureDirectoryExists(props, propKey)) {
- deleteQuietly(dir);
- forceMkdir(dir);
+ LOG.info("Cleaning and/or creating temp directory {}", dir.getAbsolutePath());
+ if (!createDirectory(props, propKey)) {
+ cleanDirectory(dir);
}
}
}