Skip to content

Commit

Permalink
Stream casblob headers when clients read from offset 0
Browse files Browse the repository at this point in the history
This should fix #751.
  • Loading branch information
mostynb committed May 29, 2024
1 parent 1b2f853 commit b38efe2
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions cache/disk/casblob/casblob.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,20 @@ func GetZstdReadCloser(zstd zstdimpl.ZstdImpl, f *os.File, expectedSize int64, o
h.compression)
}

if offset == 0 {
// Special case for full reads: stream the header also.
//
// When using compressed storage mode and the grpc proxy backend, the
// frontend bazel-remote expects to receive the casblob header.

_, err = f.Seek(0, io.SeekStart)
if err != nil {
return nil, fmt.Errorf("failed to seek to start of file: %w", err)
}

return f, nil
}

// Find the first relevant chunk.
chunkNum := int64(offset / int64(h.chunkSize))
remainder := offset % int64(h.chunkSize)
Expand Down

0 comments on commit b38efe2

Please sign in to comment.