103
103
import com .google .storage .v2 .NotificationConfigName ;
104
104
import com .google .storage .v2 .Object ;
105
105
import com .google .storage .v2 .ObjectAccessControl ;
106
- import com .google .storage .v2 .ObjectChecksums ;
107
106
import com .google .storage .v2 .ReadObjectRequest ;
108
107
import com .google .storage .v2 .RewriteObjectRequest ;
109
108
import com .google .storage .v2 .RewriteResponse ;
@@ -233,7 +232,7 @@ public Blob create(
233
232
GrpcCallContext grpcCallContext =
234
233
opts .grpcMetadataMapper ().apply (GrpcCallContext .createDefault ());
235
234
WriteObjectRequest req = getWriteObjectRequest (blobInfo , opts );
236
- Hasher hasher = getHasherForRequest ( req , Hasher .enabled () );
235
+ Hasher hasher = Hasher .enabled ();
237
236
GrpcCallContext merge = Utils .merge (grpcCallContext , Retrying .newCallContext ());
238
237
return Retrying .run (
239
238
getOptions (),
@@ -286,8 +285,6 @@ public Blob createFrom(BlobInfo blobInfo, Path path, int bufferSize, BlobWriteOp
286
285
opts .grpcMetadataMapper ().apply (GrpcCallContext .createDefault ());
287
286
WriteObjectRequest req = getWriteObjectRequest (blobInfo , opts );
288
287
289
- Hasher hasher = getHasherForRequest (req , Hasher .enabled ());
290
-
291
288
long size = Files .size (path );
292
289
if (size < bufferSize ) {
293
290
// ignore the bufferSize argument if the file is smaller than it
@@ -300,7 +297,7 @@ public Blob createFrom(BlobInfo blobInfo, Path path, int bufferSize, BlobWriteOp
300
297
ResumableMedia .gapic ()
301
298
.write ()
302
299
.byteChannel (storageClient .writeObjectCallable ().withDefaultCallContext (merge ))
303
- .setHasher (hasher )
300
+ .setHasher (Hasher . enabled () )
304
301
.setByteStringStrategy (ByteStringStrategy .noCopy ())
305
302
.direct ()
306
303
.buffered (Buffers .allocate (size ))
@@ -323,7 +320,7 @@ public Blob createFrom(BlobInfo blobInfo, Path path, int bufferSize, BlobWriteOp
323
320
.write ()
324
321
.byteChannel (
325
322
storageClient .writeObjectCallable ().withDefaultCallContext (grpcCallContext ))
326
- .setHasher (hasher )
323
+ .setHasher (Hasher . noop () )
327
324
.setByteStringStrategy (ByteStringStrategy .noCopy ())
328
325
.resumable ()
329
326
.withRetryConfig (getOptions (), retryAlgorithmManager .idempotent ())
@@ -359,13 +356,12 @@ public Blob createFrom(
359
356
360
357
ApiFuture <ResumableWrite > start = startResumableWrite (grpcCallContext , req );
361
358
362
- Hasher hasher = getHasherForRequest (req , Hasher .enabled ());
363
359
BufferedWritableByteChannelSession <WriteObjectResponse > session =
364
360
ResumableMedia .gapic ()
365
361
.write ()
366
362
.byteChannel (
367
363
storageClient .writeObjectCallable ().withDefaultCallContext (grpcCallContext ))
368
- .setHasher (hasher )
364
+ .setHasher (Hasher . noop () )
369
365
.setByteStringStrategy (ByteStringStrategy .noCopy ())
370
366
.resumable ()
371
367
.withRetryConfig (getOptions (), retryAlgorithmManager .idempotent ())
@@ -739,7 +735,7 @@ public GrpcBlobWriteChannel writer(BlobInfo blobInfo, BlobWriteOption... options
739
735
GrpcCallContext grpcCallContext =
740
736
opts .grpcMetadataMapper ().apply (GrpcCallContext .createDefault ());
741
737
WriteObjectRequest req = getWriteObjectRequest (blobInfo , opts );
742
- Hasher hasher = getHasherForRequest ( req , Hasher .enabled () );
738
+ Hasher hasher = Hasher .noop ( );
743
739
return new GrpcBlobWriteChannel (
744
740
storageClient .writeObjectCallable (),
745
741
getOptions (),
@@ -1967,19 +1963,6 @@ private Object updateObject(UpdateObjectRequest req) {
1967
1963
Decoder .identity ());
1968
1964
}
1969
1965
1970
- private static Hasher getHasherForRequest (WriteObjectRequest req , Hasher defaultHasher ) {
1971
- if (!req .hasObjectChecksums ()) {
1972
- return defaultHasher ;
1973
- } else {
1974
- ObjectChecksums checksums = req .getObjectChecksums ();
1975
- if (!checksums .hasCrc32C () && checksums .getMd5Hash ().isEmpty ()) {
1976
- return defaultHasher ;
1977
- } else {
1978
- return Hasher .noop ();
1979
- }
1980
- }
1981
- }
1982
-
1983
1966
@ Nullable
1984
1967
private Blob internalBlobGet (BlobId blob , Opts <ObjectSourceOpt > unwrap ) {
1985
1968
Opts <ObjectSourceOpt > opts = unwrap .resolveFrom (blob ).prepend (defaultOpts );
0 commit comments