MCPcopy
hub / github.com/rclone/rclone / readDataFromRemote

Method readDataFromRemote

backend/cache/cache_internal_test.go:1038–1052  ·  view source on GitHub ↗
(t *testing.T, f fs.Fs, remote string, offset, end int64, noLengthCheck bool)

Source from the content-addressed store, hash-verified

1036}
1037
1038func (r *run) readDataFromRemote(t *testing.T, f fs.Fs, remote string, offset, end int64, noLengthCheck bool) ([]byte, error) {
1039 size := end - offset
1040 checkSample := make([]byte, size)
1041
1042 co, err := f.NewObject(context.Background(), remote)
1043 if err != nil {
1044 return checkSample, err
1045 }
1046 checkSample = r.readDataFromObj(t, co, offset, end, noLengthCheck)
1047
1048 if !noLengthCheck && size != int64(len(checkSample)) {
1049 return checkSample, fmt.Errorf("read size doesn't match expected: %v <> %v", len(checkSample), size)
1050 }
1051 return checkSample, nil
1052}
1053
1054func (r *run) readDataFromObj(t *testing.T, o fs.Object, offset, end int64, noLengthCheck bool) []byte {
1055 size := end - offset

Calls 3

readDataFromObjMethod · 0.95
NewObjectMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected