MCPcopy Create free account
hub / github.com/OpenListTeam/OpenList / GetRangeReaderFromMFile

Function GetRangeReaderFromMFile

internal/stream/util.go:124–134  ·  view source on GitHub ↗
(size int64, file model.File)

Source from the content-addressed store, hash-verified

122}
123
124func GetRangeReaderFromMFile(size int64, file model.File) *model.FileRangeReader {
125 return &model.FileRangeReader{
126 RangeReaderIF: RangeReaderFunc(func(ctx context.Context, httpRange http_range.Range) (io.ReadCloser, error) {
127 length := httpRange.Length
128 if length < 0 || httpRange.Start+length > size {
129 length = size - httpRange.Start
130 }
131 return &model.FileCloser{File: io.NewSectionReader(file, httpRange.Start, length)}, nil
132 }),
133 }
134}
135
136// 139 cloud does not properly return 206 http status code, add a hack here
137func checkContentRange(header *http.Header, offset int64) bool {

Callers 6

getLyricLinkMethod · 0.92
LinkMethod · 0.92
LinkMethod · 0.92
LinkMethod · 0.92
LinkMethod · 0.92
LinkMethod · 0.92

Calls 1

RangeReaderFuncFuncType · 0.85

Tested by

no test coverage detected