Skip to content

Commit 0c14107

Browse files
tyler-frenchCopilot
andcommitted
Apply suggestion from @Copilot
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 277eea1 commit 0c14107

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

server/remote_cache/capabilities_server/capabilities_server.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,19 @@ func (s *CapabilitiesServer) GetCapabilities(ctx context.Context, req *repb.GetC
9393
}
9494

9595
if chunkingEnabled {
96-
c.CacheCapabilities.FastCdc_2020Params = &repb.FastCdc2020Params{
97-
AvgChunkSizeBytes: uint64(chunking.MaxChunkSizeBytes() / 4),
98-
Seed: 0,
96+
maxChunkSizeBytes := chunking.MaxChunkSizeBytes()
97+
if maxChunkSizeBytes > 0 {
98+
avgChunkSizeBytes := maxChunkSizeBytes / 4
99+
const (
100+
minAvgChunkSizeBytes = 1024 // 1 KiB
101+
maxAvgChunkSizeBytes = 1024 * 1024 // 1 MiB
102+
)
103+
if avgChunkSizeBytes >= minAvgChunkSizeBytes && avgChunkSizeBytes <= maxAvgChunkSizeBytes {
104+
c.CacheCapabilities.FastCdc_2020Params = &repb.FastCdc2020Params{
105+
AvgChunkSizeBytes: uint64(avgChunkSizeBytes),
106+
Seed: 0,
107+
}
108+
}
99109
}
100110
}
101111
}

server/remote_cache/content_addressable_storage_server/content_addressable_storage_server.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,8 +1167,16 @@ func (s *ContentAddressableStorageServer) SpliceBlob(ctx context.Context, req *r
11671167
return nil, status.UnimplementedErrorf("SpliceBlob RPC is not currently enabled")
11681168
}
11691169

1170-
if cf := req.GetChunkingFunction(); cf != repb.ChunkingFunction_FAST_CDC_2020 {
1171-
return nil, status.InvalidArgumentErrorf("unsupported chunking function %v, only FAST_CDC_2020 is supported", cf)
1170+
cf := req.GetChunkingFunction()
1171+
if cf != repb.ChunkingFunction_UNKNOWN && cf != repb.ChunkingFunction_FAST_CDC_2020 {
1172+
return nil, status.InvalidArgumentErrorf("unsupported chunking function %v", cf)
1173+
}
1174+
1175+
// REAPI requires servers accept UNKNOWN; no-op since we only store FastCDC.
1176+
if cf == repb.ChunkingFunction_UNKNOWN {
1177+
return &repb.SpliceBlobResponse{
1178+
BlobDigest: req.GetBlobDigest(),
1179+
}, nil
11721180
}
11731181

11741182
if req.GetBlobDigest() == nil {

0 commit comments

Comments
 (0)