chore(weed/util/chunk_cache): remove unused functions (#9372)

* chore(weed/util/chunk_cache): remove unused functions

* fix(chunk_cache): bound ReadAt buffer in readNeedleSliceAt

When the caller-provided buffer is larger than the remaining needle
bytes, ReadAt would spill into the next needle and trigger the
n != wanted error. Slice to data[:wanted] so the read stops at the
needle boundary.

---------

Co-authored-by: Chris Lu <chris.lu@gmail.com>
This commit is contained in:
Lars LehtonenandChris Lu authored and GitHub committed 2026-05-08 13:12:11 -07:00
1 parent fd463155e4
commit 935fb42e1d
3 files changed
+1 -92

No files matched your search

@@ -63,50 +63,6 @@ func (c *OnDiskCacheLayer) setChunk(needleId types.NeedleId, data []byte) {
}
func (c *OnDiskCacheLayer) getChunk(needleId types.NeedleId) (data []byte) {
var err error
for _, diskCache := range c.diskCaches {
data, err = diskCache.GetNeedle(needleId)
if err == storage.ErrorNotFound {
continue
}
if err != nil {
glog.Errorf("failed to read cache file %s id %d", diskCache.fileName, needleId)
continue
}
if len(data) != 0 {
return
}
}
return nil
}
func (c *OnDiskCacheLayer) getChunkSlice(needleId types.NeedleId, offset, length uint64) (data []byte) {
var err error
for _, diskCache := range c.diskCaches {
data, err = diskCache.getNeedleSlice(needleId, offset, length)
if err == storage.ErrorNotFound {
continue
}
if err != nil {
glog.Warningf("failed to read cache file %s id %d: %v", diskCache.fileName, needleId, err)
continue
}
if len(data) != 0 {
return
}
}
return nil
}
func (c *OnDiskCacheLayer) readChunkAt(buffer []byte, needleId types.NeedleId, offset uint64) (n int, err error) {
for _, diskCache := range c.diskCaches {