diff --git a/openbis-common/.gitignore b/openbis-common/.gitignore index 1fec20e5e233b5b25d286737b27f6647c5bd51b9..52acc8f8fb5254d659fc127e405f947e8b2de2c4 100644 --- a/openbis-common/.gitignore +++ b/openbis-common/.gitignore @@ -2,3 +2,7 @@ /temp-testng-customsuite.xml /test-output /bin +/build +.classpath +.project +.settings diff --git a/openbis-common/source/java/ch/systemsx/cisd/openbis/common/io/hierarchical_content/TarBasedHierarchicalContent.java b/openbis-common/source/java/ch/systemsx/cisd/openbis/common/io/hierarchical_content/TarBasedHierarchicalContent.java index aad5b34fe44ad8610827046836bdc24b1feb1148..0a6e7f35ec4ef13627687d0c84f95c6c228df2ea 100644 --- a/openbis-common/source/java/ch/systemsx/cisd/openbis/common/io/hierarchical_content/TarBasedHierarchicalContent.java +++ b/openbis-common/source/java/ch/systemsx/cisd/openbis/common/io/hierarchical_content/TarBasedHierarchicalContent.java @@ -33,13 +33,16 @@ import ch.systemsx.cisd.openbis.common.io.hierarchical_content.api.IHierarchical public class TarBasedHierarchicalContent extends AbstractHierarchicalContent { - private File packageFile; + private final File packageFile; private File extractTo; - public TarBasedHierarchicalContent(File packageFile) + private final File tempFolder; + + public TarBasedHierarchicalContent(File packageFile, File tempFolder) { this.packageFile = packageFile; + this.tempFolder = tempFolder; } @Override @@ -87,6 +90,18 @@ public class TarBasedHierarchicalContent extends AbstractHierarchicalContent } } + private File getTempFolder() + { + + if (tempFolder != null) + { + return tempFolder; + } else + { + return new File(System.getProperty("java.io.tmpdir")); + } + } + private void maybeExtract() { if (extractTo == null) @@ -95,7 +110,7 @@ public class TarBasedHierarchicalContent extends AbstractHierarchicalContent try { - File temp = new File(System.getProperty("java.io.tmpdir")); + File temp = getTempFolder(); extractTo = new File(temp, UUID.randomUUID().toString()); extractTo.mkdirs(); diff --git a/openbis-common/sourceTest/java/ch/systemsx/cisd/openbis/common/io/hierarchical_content/TarBasedHierarchicalContentTest.java b/openbis-common/sourceTest/java/ch/systemsx/cisd/openbis/common/io/hierarchical_content/TarBasedHierarchicalContentTest.java index e258fd7187480f8d8d6c1da98ca61ffc7b61fd04..260d8fb2f6a6f957dd7221e91a650ccbba7893af 100644 --- a/openbis-common/sourceTest/java/ch/systemsx/cisd/openbis/common/io/hierarchical_content/TarBasedHierarchicalContentTest.java +++ b/openbis-common/sourceTest/java/ch/systemsx/cisd/openbis/common/io/hierarchical_content/TarBasedHierarchicalContentTest.java @@ -35,7 +35,7 @@ public class TarBasedHierarchicalContentTest extends AbstractPackageBasedHierarc { tar = new Tar(packageFile); tar.add(dataDir, dataDir.getPath().length()); - return new TarBasedHierarchicalContent(packageFile); + return new TarBasedHierarchicalContent(packageFile, null); } finally { if (tar != null)