mirror of https://github.com/apache/jclouds.git
Delete GCS composite object components
Previously we left dangling subobjects. The composite object retains a reference to the components data.
This commit is contained in:
parent
c2a22bc32c
commit
ed262f7bd6
|
@ -384,9 +384,9 @@ public final class GoogleCloudStorageBlobStore extends BaseBlobStore {
|
|||
|
||||
@Override
|
||||
public String completeMultipartUpload(MultipartUpload mpu, List<MultipartPart> parts) {
|
||||
ImmutableList.Builder<GoogleCloudStorageObject> builder = ImmutableList.builder();
|
||||
ImmutableList.Builder<GoogleCloudStorageObject> objects = ImmutableList.builder();
|
||||
for (MultipartPart part : parts) {
|
||||
builder.add(api.getObjectApi().getObject(mpu.containerName(),
|
||||
objects.add(api.getObjectApi().getObject(mpu.containerName(),
|
||||
Strings2.urlEncode(getMPUPartName(mpu, part.partNumber()))));
|
||||
}
|
||||
|
||||
|
@ -400,11 +400,20 @@ public final class GoogleCloudStorageBlobStore extends BaseBlobStore {
|
|||
destination.addAcl(controls);
|
||||
}
|
||||
|
||||
ComposeObjectTemplate template = ComposeObjectTemplate.builder().fromGoogleCloudStorageObject(builder.build())
|
||||
ComposeObjectTemplate template = ComposeObjectTemplate.builder()
|
||||
.fromGoogleCloudStorageObject(objects.build())
|
||||
.destination(destination).build();
|
||||
return api.getObjectApi().composeObjects(mpu.containerName(), Strings2.urlEncode(mpu.blobName()), template)
|
||||
String eTag = api.getObjectApi().composeObjects(mpu.containerName(), Strings2.urlEncode(mpu.blobName()), template)
|
||||
.etag();
|
||||
// TODO: delete components?
|
||||
|
||||
// remove parts, composite object keeps a reference to them
|
||||
ImmutableList.Builder<String> builder = ImmutableList.builder();
|
||||
for (MultipartPart part : parts) {
|
||||
builder.add(getMPUPartName(mpu, part.partNumber()));
|
||||
}
|
||||
removeBlobs(mpu.containerName(), builder.build());
|
||||
|
||||
return eTag;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -18,10 +18,8 @@ package org.jclouds.googlecloudstorage.blobstore.integration;
|
|||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNotEquals;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
import static org.testng.Assert.assertNull;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
@ -224,9 +222,7 @@ public class GoogleCloudStorageBlobIntegrationLiveTest extends BaseBlobIntegrati
|
|||
addMultipartBlobToContainer(containerName, "const.txt");
|
||||
|
||||
long countAfter = blobStore.countBlobs(containerName);
|
||||
assertNotEquals(countBefore, countAfter, "No blob was created");
|
||||
assertTrue(countAfter - countBefore > 1, "A multipart blob wasn't actually created - "
|
||||
+ "there was only 1 extra blob but there should be one manifest blob and multiple chunk blobs");
|
||||
assertThat(countAfter).isEqualTo(countBefore + 1);
|
||||
} finally {
|
||||
returnContainer(containerName);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue