Fix replacing metadata in BaseBlobStore

Fixes Atmos errors.  Uncovered by removing unneeded addContentMetadata
call in BaseBlobIntegrationTest.testCopyBlobReplaceMetadata.
This commit is contained in:
Andrew Gaul 2016-01-15 04:13:04 -08:00
parent b63f74a6eb
commit 688890819e
2 changed files with 14 additions and 8 deletions

View File

@ -262,18 +262,25 @@ public abstract class BaseBlobStore implements BlobStore {
InputStream is = null; InputStream is = null;
try { try {
is = blob.getPayload().openStream(); is = blob.getPayload().openStream();
ContentMetadata metadata = blob.getMetadata().getContentMetadata();
BlobBuilder.PayloadBlobBuilder builder = blobBuilder(toName) BlobBuilder.PayloadBlobBuilder builder = blobBuilder(toName)
.payload(is) .payload(is);
.cacheControl(metadata.getCacheControl()) Long contentLength = blob.getMetadata().getContentMetadata().getContentLength();
if (contentLength != null) {
builder.contentLength(contentLength);
}
ContentMetadata metadata;
if (options.getContentMetadata().isPresent()) {
metadata = options.getContentMetadata().get();
} else {
metadata = blob.getMetadata().getContentMetadata();
}
builder.cacheControl(metadata.getCacheControl())
.contentDisposition(metadata.getContentDisposition()) .contentDisposition(metadata.getContentDisposition())
.contentEncoding(metadata.getContentEncoding()) .contentEncoding(metadata.getContentEncoding())
.contentLanguage(metadata.getContentLanguage()) .contentLanguage(metadata.getContentLanguage())
.contentType(metadata.getContentType()); .contentType(metadata.getContentType());
Long contentLength = metadata.getContentLength();
if (contentLength != null) {
builder.contentLength(contentLength);
}
Optional<Map<String, String>> userMetadata = options.getUserMetadata(); Optional<Map<String, String>> userMetadata = options.getUserMetadata();
if (userMetadata.isPresent()) { if (userMetadata.isPresent()) {
builder.userMetadata(userMetadata.get()); builder.userMetadata(userMetadata.get());

View File

@ -906,7 +906,6 @@ public class BaseBlobIntegrationTest extends BaseBlobStoreIntegrationTest {
.contentEncoding("compress") .contentEncoding("compress")
.contentLanguage("fr") .contentLanguage("fr")
.contentType("audio/ogg"); .contentType("audio/ogg");
addContentMetadata(blobBuilder);
Blob blob = blobBuilder.build(); Blob blob = blobBuilder.build();
String fromContainer = getContainerName(); String fromContainer = getContainerName();