From 0563077fb959be890bb15c071ea1ef8f2be8ec04 Mon Sep 17 00:00:00 2001 From: Jeremy Long Date: Sat, 5 Oct 2013 07:40:39 -0400 Subject: [PATCH] fixed bug with delete on exit deleting updated files Former-commit-id: d26151e944f5af674c256a37694c1e5eaed4b8cc --- .../dependencycheck/utils/FileUtils.java | 35 ++++--------------- 1 file changed, 6 insertions(+), 29 deletions(-) diff --git a/dependency-check-core/src/main/java/org/owasp/dependencycheck/utils/FileUtils.java b/dependency-check-core/src/main/java/org/owasp/dependencycheck/utils/FileUtils.java index 107595ecf..41566f772 100644 --- a/dependency-check-core/src/main/java/org/owasp/dependencycheck/utils/FileUtils.java +++ b/dependency-check-core/src/main/java/org/owasp/dependencycheck/utils/FileUtils.java @@ -80,37 +80,14 @@ public final class FileUtils { } } if (!org.apache.commons.io.FileUtils.deleteQuietly(file)) { - //if (!file.delete()) { throw new FileNotFoundException("Failed to delete file: " + file); - } else { - file.deleteOnExit(); - } - } - - /** - * Deletes a file. If the File is a directory it will recursively delete the - * contents. - * - * @param file the File to delete - * @param deleteOnExit setting this to true will cause errors to be ignored - * and if there is an error deleting the file it will be setup to be deleted - * when the JVM exits. - * @throws IOException is thrown if the file could not be deleted - */ - public static void delete(File file, boolean deleteOnExit) throws IOException { - if (file.isDirectory()) { - for (File c : file.listFiles()) { - delete(c); - } - } - if (!org.apache.commons.io.FileUtils.deleteQuietly(file)) { - //if (!file.delete()) { - if (deleteOnExit) { - file.deleteOnExit(); - } else { - throw new FileNotFoundException("Failed to delete file: " + file); - } } + /* else { + //delete on exit was a bad idea. if for some reason the file can't be deleted + // this will cause a newly constructed file to be deleted and a subsequent run may fail. + // still not sure why a file fails to be deleted, but can be overwritten... odd. + file.deleteOnExit(); + }*/ } /**