Browse Source

Filer: fix filer range read (#7078)

* fix filer range read

Only return true if we're reading the ENTIRE chunk from the beginning.
	// This prevents bandwidth amplification when range requests happen to align
	// with chunk boundaries but don't actually want the full chunk.

* Update weed/filer/filechunks.go

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

---------

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
pull/7079/head
Chris Lu 2 months ago
committed by GitHub
parent
commit
513ac58504
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 5
      weed/filer/filechunks.go

5
weed/filer/filechunks.go

@ -178,7 +178,10 @@ func (cv *ChunkView) Clone() IntervalValue {
} }
func (cv *ChunkView) IsFullChunk() bool { func (cv *ChunkView) IsFullChunk() bool {
return cv.ViewSize == cv.ChunkSize
// IsFullChunk returns true if the view covers the entire chunk from the beginning.
// This prevents bandwidth amplification when range requests happen to align
// with chunk boundaries but don't actually want the full chunk.
return cv.OffsetInChunk == 0 && cv.ViewSize == cv.ChunkSize
} }
func ViewFromChunks(ctx context.Context, lookupFileIdFn wdclient.LookupFileIdFunctionType, chunks []*filer_pb.FileChunk, offset int64, size int64) (chunkViews *IntervalList[*ChunkView]) { func ViewFromChunks(ctx context.Context, lookupFileIdFn wdclient.LookupFileIdFunctionType, chunks []*filer_pb.FileChunk, offset int64, size int64) (chunkViews *IntervalList[*ChunkView]) {

Loading…
Cancel
Save