fixed issue #570 - each instance of dependency-check will have its own temporary folder

This commit is contained in:
Jeremy Long
2016-10-16 07:40:18 -04:00
parent 5ed0583039
commit e70c2f2b05

View File

@@ -293,7 +293,8 @@ public final class Settings {
*/
public static final String ANALYZER_COCOAPODS_ENABLED = "analyzer.cocoapods.enabled";
/**
* The properties key for whether the SWIFT package manager analyzer is enabled.
* The properties key for whether the SWIFT package manager analyzer is
* enabled.
*/
public static final String ANALYZER_SWIFT_PACKAGE_MANAGER_ENABLED = "analyzer.swift.package.manager.enabled";
/**
@@ -425,14 +426,7 @@ public final class Settings {
public static void cleanup(boolean deleteTemporary) {
if (deleteTemporary && tempDirectory != null && tempDirectory.exists()) {
FileUtils.delete(tempDirectory);
if (tempDirectory.exists()) {
try {
Thread.sleep(2000);
} catch (InterruptedException ex) {
LOGGER.trace("ignore", ex);
}
FileUtils.delete(tempDirectory);
}
tempDirectory = null;
}
try {
LOCAL_SETTINGS.remove();
@@ -746,14 +740,12 @@ public final class Settings {
* @throws java.io.IOException thrown if the temporary directory does not
* exist and cannot be created
*/
public static File getTempDirectory() throws IOException {
final File tmpDir = new File(Settings.getString(Settings.KEYS.TEMP_DIRECTORY, System.getProperty("java.io.tmpdir")), "dctemp");
if (!tmpDir.exists() && !tmpDir.mkdirs()) {
final String msg = String.format("Unable to make a temporary folder '%s'", tmpDir.getPath());
throw new IOException(msg);
public static synchronized File getTempDirectory() throws IOException {
if (tempDirectory == null) {
final File baseTemp = new File(Settings.getString(Settings.KEYS.TEMP_DIRECTORY, System.getProperty("java.io.tmpdir")));
tempDirectory = FileUtils.createTempDirectory(baseTemp);
}
tempDirectory = tmpDir;
return tmpDir;
return tempDirectory;
}
/**