Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Brandon Duffany <[email protected]>
  • Loading branch information
sluongng and bduffany authored Apr 23, 2024
1 parent 5b51111 commit aff4135
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions server/remote_asset/fetch_server/fetch_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,15 +313,15 @@ func mirrorToCache(ctx context.Context, bsClient bspb.ByteStreamClient, remoteIn
if err != nil {
return nil, status.UnavailableErrorf("failed to compute checksum digest: %s", err)
}
if expectedChecksum != "" && checksumDigestRN.GetDigest().Hash != expectedChecksum {
if expectedChecksum != "" && checksumDigestRN.GetDigest().GetHash() != expectedChecksum {
return nil, status.InvalidArgumentErrorf("response body checksum for %q was %q but wanted %q", uri, checksumDigestRN.GetDigest().Hash, expectedChecksum)
}
}
blobDigest, err := cachetools.UploadFile(ctx, bsClient, remoteInstanceName, storageFunc, tmpFilePath)
if err != nil {
return nil, status.UnavailableErrorf("failed to add object to cache: %s", err)
}
// If the requsted digestFunc is supplied is the same with the checksum sri,
// If the requested digestFunc is supplied is the same with the checksum sri,
// verify the expected checksum of the downloaded file after storing it in our cache.
if checksumFunc == storageFunc && expectedChecksum != "" && blobDigest.Hash != expectedChecksum {
return nil, status.InvalidArgumentErrorf("response body checksum for %q was %q but wanted %q", uri, blobDigest.Hash, expectedChecksum)
Expand Down

0 comments on commit aff4135

Please sign in to comment.