103103import com .google .storage .v2 .NotificationConfigName ;
104104import com .google .storage .v2 .Object ;
105105import com .google .storage .v2 .ObjectAccessControl ;
106- import com .google .storage .v2 .ObjectChecksums ;
107106import com .google .storage .v2 .ReadObjectRequest ;
108107import com .google .storage .v2 .RewriteObjectRequest ;
109108import com .google .storage .v2 .RewriteResponse ;
@@ -233,7 +232,7 @@ public Blob create(
233232 GrpcCallContext grpcCallContext =
234233 opts .grpcMetadataMapper ().apply (GrpcCallContext .createDefault ());
235234 WriteObjectRequest req = getWriteObjectRequest (blobInfo , opts );
236- Hasher hasher = getHasherForRequest ( req , Hasher .enabled () );
235+ Hasher hasher = Hasher .enabled ();
237236 GrpcCallContext merge = Utils .merge (grpcCallContext , Retrying .newCallContext ());
238237 return Retrying .run (
239238 getOptions (),
@@ -286,8 +285,6 @@ public Blob createFrom(BlobInfo blobInfo, Path path, int bufferSize, BlobWriteOp
286285 opts .grpcMetadataMapper ().apply (GrpcCallContext .createDefault ());
287286 WriteObjectRequest req = getWriteObjectRequest (blobInfo , opts );
288287
289- Hasher hasher = getHasherForRequest (req , Hasher .enabled ());
290-
291288 long size = Files .size (path );
292289 if (size < bufferSize ) {
293290 // 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
300297 ResumableMedia .gapic ()
301298 .write ()
302299 .byteChannel (storageClient .writeObjectCallable ().withDefaultCallContext (merge ))
303- .setHasher (hasher )
300+ .setHasher (Hasher . enabled () )
304301 .setByteStringStrategy (ByteStringStrategy .noCopy ())
305302 .direct ()
306303 .buffered (Buffers .allocate (size ))
@@ -323,7 +320,7 @@ public Blob createFrom(BlobInfo blobInfo, Path path, int bufferSize, BlobWriteOp
323320 .write ()
324321 .byteChannel (
325322 storageClient .writeObjectCallable ().withDefaultCallContext (grpcCallContext ))
326- .setHasher (hasher )
323+ .setHasher (Hasher . noop () )
327324 .setByteStringStrategy (ByteStringStrategy .noCopy ())
328325 .resumable ()
329326 .withRetryConfig (getOptions (), retryAlgorithmManager .idempotent ())
@@ -359,13 +356,12 @@ public Blob createFrom(
359356
360357 ApiFuture <ResumableWrite > start = startResumableWrite (grpcCallContext , req );
361358
362- Hasher hasher = getHasherForRequest (req , Hasher .enabled ());
363359 BufferedWritableByteChannelSession <WriteObjectResponse > session =
364360 ResumableMedia .gapic ()
365361 .write ()
366362 .byteChannel (
367363 storageClient .writeObjectCallable ().withDefaultCallContext (grpcCallContext ))
368- .setHasher (hasher )
364+ .setHasher (Hasher . noop () )
369365 .setByteStringStrategy (ByteStringStrategy .noCopy ())
370366 .resumable ()
371367 .withRetryConfig (getOptions (), retryAlgorithmManager .idempotent ())
@@ -739,7 +735,7 @@ public GrpcBlobWriteChannel writer(BlobInfo blobInfo, BlobWriteOption... options
739735 GrpcCallContext grpcCallContext =
740736 opts .grpcMetadataMapper ().apply (GrpcCallContext .createDefault ());
741737 WriteObjectRequest req = getWriteObjectRequest (blobInfo , opts );
742- Hasher hasher = getHasherForRequest ( req , Hasher .enabled () );
738+ Hasher hasher = Hasher .noop ( );
743739 return new GrpcBlobWriteChannel (
744740 storageClient .writeObjectCallable (),
745741 getOptions (),
@@ -1967,19 +1963,6 @@ private Object updateObject(UpdateObjectRequest req) {
19671963 Decoder .identity ());
19681964 }
19691965
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-
19831966 @ Nullable
19841967 private Blob internalBlobGet (BlobId blob , Opts <ObjectSourceOpt > unwrap ) {
19851968 Opts <ObjectSourceOpt > opts = unwrap .resolveFrom (blob ).prepend (defaultOpts );
0 commit comments