Make sure we clean all the files below the .webgoat dir

This commit is contained in:
Nanne Baars 2017-06-15 19:06:50 +02:00
parent a484467419
commit e9ad20cb30

View File

@ -24,6 +24,10 @@ public class CleanupLocalProgressFiles {
@PostConstruct @PostConstruct
public void clean() { public void clean() {
File dir = new File(webgoatHome); File dir = new File(webgoatHome);
//do it safe, check whether the subdir mongodb is available as subdirectory
File[] mongoDir = dir.listFiles(f -> f.isDirectory() && f.getName().contains("mongodb"));
if (mongoDir != null && mongoDir.length == 1) {
FileSystemUtils.deleteRecursively(dir); FileSystemUtils.deleteRecursively(dir);
} }
}
} }