From 1b4fe6135f009d7cc9bb5b6d2692d76d6359f199 Mon Sep 17 00:00:00 2001 From: Jeremy Long Date: Sat, 26 Oct 2013 17:19:55 -0400 Subject: [PATCH] attempted to fix minor bug of files not being extracted due to a failure when calling mkdirs() Former-commit-id: 2ca6840f3198adb11df764bf11a96c23885f3217 --- .../dependencycheck/analyzer/ArchiveAnalyzer.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/ArchiveAnalyzer.java b/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/ArchiveAnalyzer.java index 25bb036eb..0b78373da 100644 --- a/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/ArchiveAnalyzer.java +++ b/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/ArchiveAnalyzer.java @@ -231,6 +231,10 @@ public class ArchiveAnalyzer extends AbstractAnalyzer implements Analyzer { private File getNextTempDirectory() throws AnalysisException { dirCount += 1; final File directory = new File(tempFileLocation, String.valueOf(dirCount)); + //getting an exception for some directories not being able to be created; might be because the directory already exists? + if (directory.exists()) { + return getNextTempDirectory(); + } if (!directory.mkdirs()) { throw new AnalysisException("Unable to create temp directory '" + directory.getAbsolutePath() + "'."); } @@ -267,8 +271,10 @@ public class ArchiveAnalyzer extends AbstractAnalyzer implements Analyzer { while ((entry = zis.getNextZipEntry()) != null) { if (entry.isDirectory()) { final File d = new File(extractTo, entry.getName()); - if (!d.mkdirs()) { - throw new AnalysisException("Unable to create '" + d.getAbsolutePath() + "'."); + if (!d.exists()) { + if (!d.mkdirs()) { + throw new AnalysisException("Unable to create '" + d.getAbsolutePath() + "'."); + } } } else { final File file = new File(extractTo, entry.getName());