From 60811de15df70cd5fa0a1d18acc7577c673e9484 Mon Sep 17 00:00:00 2001 From: Sébastien Lesaint Date: Thu, 11 Feb 2016 13:42:30 +0100 Subject: SONAR-7125 use efficient delete dir method in sonar-process --- .../java/org/sonar/application/AppFileSystem.java | 34 +--------------------- 1 file changed, 1 insertion(+), 33 deletions(-) (limited to 'sonar-application/src/main') 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 { - 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; - } - } } -- cgit v1.2.3 GroupBy'>addAllToGroupBy Nextcloud server, a safe home for all your data: https://github.com/nextcloud/serverwww-data
summaryrefslogtreecommitdiffstats
blob: 880d4d8b20b1d6b11506be319a91156cf570b8f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59