Skip to content
Closed
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 @@ -22,7 +22,6 @@
import com.google.api.core.ApiFuture;
import com.google.api.core.ApiFutures;
import com.google.api.core.BetaApi;
import com.google.api.core.InternalApi;
import com.google.api.core.SettableApiFuture;
import com.google.cloud.storage.BidiUploadState.AppendableUploadState;
import com.google.cloud.storage.BidiUploadState.TakeoverAppendableUploadState;
Expand Down Expand Up @@ -53,18 +52,13 @@ public final class BlobAppendableUploadConfig {

private static final BlobAppendableUploadConfig INSTANCE =
new BlobAppendableUploadConfig(
FlushPolicy.minFlushSize(_256KiB),
Hasher.enabled(),
CloseAction.CLOSE_WITHOUT_FINALIZING);
FlushPolicy.minFlushSize(_256KiB), CloseAction.CLOSE_WITHOUT_FINALIZING);

private final FlushPolicy flushPolicy;
private final Hasher hasher;
private final CloseAction closeAction;

private BlobAppendableUploadConfig(
FlushPolicy flushPolicy, Hasher hasher, CloseAction closeAction) {
private BlobAppendableUploadConfig(FlushPolicy flushPolicy, CloseAction closeAction) {
this.flushPolicy = flushPolicy;
this.hasher = hasher;
this.closeAction = closeAction;
}

Expand Down Expand Up @@ -96,7 +90,7 @@ public BlobAppendableUploadConfig withFlushPolicy(FlushPolicy flushPolicy) {
if (this.flushPolicy.equals(flushPolicy)) {
return this;
}
return new BlobAppendableUploadConfig(flushPolicy, hasher, closeAction);
return new BlobAppendableUploadConfig(flushPolicy, closeAction);
}

/**
Expand Down Expand Up @@ -126,45 +120,7 @@ public BlobAppendableUploadConfig withCloseAction(CloseAction closeAction) {
if (this.closeAction == closeAction) {
return this;
}
return new BlobAppendableUploadConfig(flushPolicy, hasher, closeAction);
}

/**
* Whether crc32c validation will be performed for bytes returned by Google Cloud Storage
*
* <p><i>Default:</i> {@code true}
*
* @since 2.51.0 This new api is in preview and is subject to breaking changes.
*/
@BetaApi
boolean getCrc32cValidationEnabled() {
return Hasher.enabled().equals(hasher);
}

/**
* Return an instance with crc32c validation enabled based on {@code enabled}.
*
* <p><i>Default:</i> {@code true}
*
* @param enabled Whether crc32c validation will be performed for bytes returned by Google Cloud
* Storage
* @since 2.51.0 This new api is in preview and is subject to breaking changes.
*/
@BetaApi
BlobAppendableUploadConfig withCrc32cValidationEnabled(boolean enabled) {
if (enabled && Hasher.enabled().equals(hasher)) {
return this;
} else if (!enabled && Hasher.noop().equals(hasher)) {
return this;
}
return new BlobAppendableUploadConfig(
flushPolicy, enabled ? Hasher.enabled() : Hasher.noop(), closeAction);
}

/** Never to be made public until {@link Hasher} is public */
@InternalApi
Hasher getHasher() {
return hasher;
return new BlobAppendableUploadConfig(flushPolicy, closeAction);
}

@Override
Expand Down
Loading