diff options
author | Duarte Meneses <duarte.meneses@sonarsource.com> | 2022-03-23 15:07:45 -0500 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2022-03-28 20:02:53 +0000 |
commit | 725f718cd742494ce5265e53a47cff91dfa7a37c (patch) | |
tree | ee9e6e49963b9d04baef536a927d4c28a60be00e /server/sonar-main/src/main/java | |
parent | da51806b4483467ebd5db0c5f7bbc4bbaf1bb72e (diff) | |
download | sonarqube-725f718cd742494ce5265e53a47cff91dfa7a37c.tar.gz sonarqube-725f718cd742494ce5265e53a47cff91dfa7a37c.zip |
SONAR-15987 Restart should not fail if temp files can't be deleted
Diffstat (limited to 'server/sonar-main/src/main/java')
-rw-r--r-- | server/sonar-main/src/main/java/org/sonar/application/AppFileSystem.java | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/server/sonar-main/src/main/java/org/sonar/application/AppFileSystem.java b/server/sonar-main/src/main/java/org/sonar/application/AppFileSystem.java index bc67eb3289f..e6f547c462a 100644 --- a/server/sonar-main/src/main/java/org/sonar/application/AppFileSystem.java +++ b/server/sonar-main/src/main/java/org/sonar/application/AppFileSystem.java @@ -32,12 +32,12 @@ import java.util.EnumSet; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.sonar.application.config.AppSettings; +import org.sonar.core.util.FileUtils; import org.sonar.process.sharedmemoryfile.AllProcessesCommands; import static java.lang.String.format; import static java.nio.file.FileVisitResult.CONTINUE; import static org.apache.commons.io.FileUtils.forceMkdir; -import static org.sonar.process.FileUtils2.deleteDirectory; import static org.sonar.process.ProcessProperties.Property.PATH_DATA; import static org.sonar.process.ProcessProperties.Property.PATH_LOGS; import static org.sonar.process.ProcessProperties.Property.PATH_TEMP; @@ -111,22 +111,19 @@ public class AppFileSystem implements FileSystem { } @Override - public FileVisitResult visitFile(Path filePath, BasicFileAttributes attrs) throws IOException { - File file = filePath.toFile(); - if (file.isDirectory()) { - deleteDirectory(file); - } else if (filePath.getFileName().equals(SHAREDMEMORY_FILE)) { + public FileVisitResult visitFile(Path filePath, BasicFileAttributes attrs) { + if (filePath.getFileName().equals(SHAREDMEMORY_FILE)) { return CONTINUE; } else if (!symLink || !filePath.equals(path)) { - Files.delete(filePath); + FileUtils.deleteQuietly(filePath); } return CONTINUE; } @Override - public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException { + public FileVisitResult postVisitDirectory(Path dir, IOException exc) { if (!dir.equals(path)) { - deleteDirectory(dir.toFile()); + FileUtils.deleteQuietly(dir); } return CONTINUE; } |