这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1025,7 +1025,9 @@ private ParallelCompositeUploadWriterFactory(
@Override
public WritableByteChannelSession<?, BlobInfo> writeSession(
StorageInternal s, BlobInfo info, Opts<ObjectTargetOpt> opts) {
return new PCUSession(s, info, opts);
// if crc32cMatch or md5Match were specified, they will already be in opts
BlobInfo trimmed = info.toBuilder().clearCrc32c().clearMd5().build();
return new PCUSession(s, trimmed, opts);
}

private final class PCUSession
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ private ApiFuture<BlobInfo> cleanupParts(BlobInfo finalInfo) {

private BlobInfo definePart(BlobInfo ultimateObject, PartRange partRange, long offset) {
BlobId id = ultimateObject.getBlobId();
BlobInfo.Builder b = ultimateObject.toBuilder();
BlobInfo.Builder b = ultimateObject.toBuilder().clearCrc32c().clearMd5();
String partName = partNamingStrategy.fmtName(id.getName(), partRange);
b.setBlobId(BlobId.of(id.getBucket(), partName));
ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import com.google.cloud.storage.UnifiedOpts.ObjectSourceOpt;
import com.google.cloud.storage.UnifiedOpts.ObjectTargetOpt;
import com.google.cloud.storage.UnifiedOpts.Opts;
import com.google.cloud.storage.it.ChecksummedTestContent;
import com.google.cloud.storage.spi.v1.StorageRpc;
import com.google.common.base.MoreObjects;
import com.google.common.base.Preconditions;
Expand Down Expand Up @@ -810,6 +811,41 @@ public BlobInfo internalDirectUpload(
pcu.close();
}

@Test
public void partDoesNotSpecifyAnyChecksum() throws IOException {
FakeStorageInternal storageInternal =
new FakeStorageInternal() {
@Override
public BlobInfo compose(ComposeRequest composeRequest) {
BlobInfo target = composeRequest.getTarget();
if (target.getBlobId().getName().startsWith(partNamingStrategy.prefix)) {
assertThat(target.getCrc32c()).isNull();
assertThat(target.getMd5()).isNull();
}
return super.compose(composeRequest);
}
};
ChecksummedTestContent content = ChecksummedTestContent.gen(bufferCapacity * 3 - 1);
ParallelCompositeUploadWritableByteChannel pcu =
new ParallelCompositeUploadWritableByteChannel(
bufferHandlePool,
MoreExecutors.directExecutor(),
partNamingStrategy,
PartCleanupStrategy.always(),
2,
b -> b,
finalObject,
storageInternal,
info.toBuilder()
.setCrc32c(content.getCrc32cBase64())
.setMd5(content.getMd5Base64())
.build(),
opts);
pcu.write(content.asByteBuffer());

pcu.close();
}

@NonNull
private ParallelCompositeUploadWritableByteChannel defaultPcu(int maxElementsPerCompact) {
return new ParallelCompositeUploadWritableByteChannel(
Expand Down