MCPcopy Create free account
hub / github.com/Azure/peerd / FetchFile

Function FetchFile

pkg/files/files.go:26–39  ·  view source on GitHub ↗

Fetchfile gets the content of a file from the given offset using a remote reader.

(r reader.Reader, name string, offset int64, count int)

Source from the content-addressed store, hash-verified

24
25// Fetchfile gets the content of a file from the given offset using a remote reader.
26func FetchFile(r reader.Reader, name string, offset int64, count int) ([]byte, error) {
27 d := make([]byte, count)
28 l := r.Log().With().Str("name", name).Int64("offset", offset).Int("count", count).Logger()
29 l.Debug().Msg("fetch file start")
30
31 _, err := r.PreadRemote(d, offset)
32 if err != nil && err != io.EOF {
33 l.Error().Err(err).Msg("fetch file error")
34 return nil, err
35 }
36
37 l.Debug().Msg("fetch file stop")
38 return d, nil
39}

Callers 3

ReadAtMethod · 0.92
prefetchMethod · 0.92
TestFetchFileFunction · 0.85

Calls 2

LogMethod · 0.65
PreadRemoteMethod · 0.65

Tested by 1

TestFetchFileFunction · 0.68