MCPcopy
hub / github.com/rclone/rclone / GetChunk

Method GetChunk

backend/cache/storage_memory.go:46–56  ·  view source on GitHub ↗

GetChunk will retrieve a single chunk which belongs to a cached object or an error if it doesn't find it

(cachedObject *Object, offset int64)

Source from the content-addressed store, hash-verified

44
45// GetChunk will retrieve a single chunk which belongs to a cached object or an error if it doesn't find it
46func (m *Memory) GetChunk(cachedObject *Object, offset int64) ([]byte, error) {
47 key := cachedObject.abs() + "-" + strconv.FormatInt(offset, 10)
48 var data []byte
49
50 if x, found := m.db.Get(key); found {
51 data = x.([]byte)
52 return data, nil
53 }
54
55 return nil, fmt.Errorf("couldn't get cached object data at offset %v", offset)
56}
57
58// AddChunk adds a new chunk of a cached object
59func (m *Memory) AddChunk(fp string, data []byte, offset int64) error {

Callers 2

getChunkMethod · 0.45
runMethod · 0.45

Calls 3

GetMethod · 0.65
absMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected