Avoid creating temporary files via relative paths

This avoids creating junk in the source directory.
This commit is contained in:
Andrew Gaul 2016-11-07 10:43:32 -08:00
parent 970f521bcd
commit f2413cd191
2 changed files with 8 additions and 3 deletions

View File

@ -679,7 +679,7 @@ public class RegionScopedSwiftBlobStore implements BlobStore {
ListeningExecutorService listeningExecutor = MoreExecutors.listeningDecorator(executor);
RandomAccessFile raf = null;
File tempFile = new File(destination.getName() + "." + UUID.randomUUID());
File tempFile = new File(destination + "." + UUID.randomUUID());
try {
long contentLength = api
.getObjectApi(regionId, container)

View File

@ -56,7 +56,7 @@ import com.google.common.util.concurrent.MoreExecutors;
@Test(groups = "live", singleThreaded = true)
public class RegionScopedSwiftBlobStoreParallelLiveTest extends BaseBlobStoreIntegrationTest {
private final File BIG_FILE = new File("random.dat");
private final File BIG_FILE;
private final long SIZE = 10 * 1000 * 1000;
private BlobStore blobStore;
private String ETAG;
@ -71,6 +71,11 @@ public class RegionScopedSwiftBlobStoreParallelLiveTest extends BaseBlobStoreInt
public RegionScopedSwiftBlobStoreParallelLiveTest() {
provider = "openstack-swift";
try {
BIG_FILE = File.createTempFile("random", "dat");
} catch (IOException ioe) {
throw new RuntimeException(ioe);
}
}
// Override as needed for the right region
@ -121,7 +126,7 @@ public class RegionScopedSwiftBlobStoreParallelLiveTest extends BaseBlobStoreInt
@Test(dependsOnMethods = "uploadMultipartBlob", singleThreaded = true)
public void downloadParallelBlob() throws IOException {
final File downloadedFile = new File(BIG_FILE.getName() + ".downloaded");
final File downloadedFile = new File(BIG_FILE + ".downloaded");
blobStore.downloadBlob(CONTAINER, BIG_FILE.getName(), downloadedFile, executor);
String eTag = Files.hash(downloadedFile, Hashing.md5()).toString();
assertEquals(eTag, ETAG);