Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update grpc bidi resumable uploads to validate ack'd object size #2570

Merged
merged 6 commits into from
Jun 13, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public StartResumableWriteResponse getRes() {

@Override
public BidiWriteObjectRequest.Builder newBuilder() {
return writeRequest.toBuilder();
return writeRequest.toBuilder().clearWriteObjectSpec();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

package com.google.cloud.storage;

import static com.google.cloud.storage.StorageV2ProtoUtils.fmtProto;

import com.google.cloud.storage.BidiWriteCtx.BidiWriteObjectRequestBuilderFactory;
import com.google.cloud.storage.Crc32cValue.Crc32cLengthKnown;
import com.google.storage.v2.BidiWriteObjectRequest;
Expand Down Expand Up @@ -84,36 +82,5 @@ interface BidiWriteObjectRequestBuilderFactory {

@Nullable
String bucketName();

static BidiSimpleWriteObjectRequestBuilderFactory simple(BidiWriteObjectRequest req) {
return new BidiSimpleWriteObjectRequestBuilderFactory(req);
}
}

static final class BidiSimpleWriteObjectRequestBuilderFactory
implements BidiWriteObjectRequestBuilderFactory {
private final BidiWriteObjectRequest req;

private BidiSimpleWriteObjectRequestBuilderFactory(BidiWriteObjectRequest req) {
this.req = req;
}

@Override
public BidiWriteObjectRequest.Builder newBuilder() {
return req.toBuilder();
}

@Override
public @Nullable String bucketName() {
if (req.hasWriteObjectSpec() && req.getWriteObjectSpec().hasResource()) {
return req.getWriteObjectSpec().getResource().getBucket();
}
return null;
}

@Override
public String toString() {
return "SimpleBidiWriteObjectRequestBuilderFactory{" + "req=" + fmtProto(req) + '}';
}
}
}
Loading
Loading