diff options
author | Sébastien Lesaint <sebastien.lesaint@sonarsource.com> | 2016-02-11 13:42:30 +0100 |
---|---|---|
committer | Sébastien Lesaint <sebastien.lesaint@sonarsource.com> | 2016-02-12 13:48:36 +0100 |
commit | 60811de15df70cd5fa0a1d18acc7577c673e9484 (patch) | |
tree | d97f1cd1828c09fcb0d03049243d88a57a125124 /sonar-application/src/main | |
parent | 0008f4ed732f47528bddc1392f2afd74a978cd25 (diff) | |
download | sonarqube-60811de15df70cd5fa0a1d18acc7577c673e9484.tar.gz sonarqube-60811de15df70cd5fa0a1d18acc7577c673e9484.zip |
SONAR-7125 use efficient delete dir method in sonar-process
Diffstat (limited to 'sonar-application/src/main')
-rw-r--r-- | sonar-application/src/main/java/org/sonar/application/AppFileSystem.java | 34 |
1 files changed, 1 insertions, 33 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 0f513928c98..c195008a638 100644 --- a/sonar-application/src/main/java/org/sonar/application/AppFileSystem.java +++ b/sonar-application/src/main/java/org/sonar/application/AppFileSystem.java @@ -21,19 +21,13 @@ package org.sonar.application; import java.io.File; import java.io.IOException; -import java.nio.file.FileVisitResult; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.nio.file.SimpleFileVisitor; -import java.nio.file.attribute.BasicFileAttributes; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.sonar.process.Props; import org.sonar.process.monitor.FileSystem; -import static java.nio.file.Files.delete; -import static java.nio.file.Files.walkFileTree; import static org.apache.commons.io.FileUtils.forceMkdir; +import static org.sonar.process.FileUtils.cleanDirectory; import static org.sonar.process.ProcessProperties.PATH_DATA; import static org.sonar.process.ProcessProperties.PATH_HOME; import static org.sonar.process.ProcessProperties.PATH_LOGS; @@ -123,30 +117,4 @@ public class AppFileSystem implements FileSystem { } } - private static void cleanDirectory(File dir) throws IOException { - Path path = Paths.get(dir.toURI()); - walkFileTree(path, new CleanRecursivelyFileVisitor(path)); - } - - private static class CleanRecursivelyFileVisitor extends SimpleFileVisitor<Path> { - private final Path path; - - public CleanRecursivelyFileVisitor(Path path) { - this.path = path; - } - - @Override - public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { - delete(file); - return FileVisitResult.CONTINUE; - } - - @Override - public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException { - if (!dir.equals(path)) { - delete(dir); - } - return FileVisitResult.CONTINUE; - } - } } |