Skip to content

Commit

Permalink
Implement unambiguous compressed blobs bytestream upload early return
Browse files Browse the repository at this point in the history
This is an implementation of this REAPI spec update:
bazelbuild/remote-apis#213

Which is part of the solution to this issue:
bazelbuild/bazel#14654
  • Loading branch information
mostynb committed Feb 23, 2022
1 parent b013593 commit aad9c55
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion server/grpc_bytestream.go
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,11 @@ func (s *grpcServer) Write(srv bytestream.ByteStream_WriteServer) error {
exists, _ := s.cache.Contains(srv.Context(), cache.CAS, hash, size)
if exists {
// Blob already exists, return without writing anything.
resp.CommittedSize = size
if cmp == casblob.Identity {
resp.CommittedSize = size
} else {
resp.CommittedSize = -1
}
putResult <- io.EOF
return
}
Expand Down
2 changes: 1 addition & 1 deletion server/grpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -978,7 +978,7 @@ func TestGrpcByteStreamZstdWrite(t *testing.T) {
if err != nil {
t.Fatal(err)
}
if bswResp.CommittedSize != int64(len(compressedBlob)) {
if bswResp.CommittedSize != int64(len(compressedBlob)) && bswResp.CommittedSize != -1 {
t.Fatalf("Error: expected to write: %d but committed: %d\n",
len(testBlob), bswResp.CommittedSize)
}
Expand Down

0 comments on commit aad9c55

Please sign in to comment.