MCPcopy
hub / github.com/perkeep/perkeep / NewFileReader

Method NewFileReader

pkg/schema/filereader.go:108–121  ·  view source on GitHub ↗

NewFileReader returns a new FileReader, reading bytes and blobs from the provided fetcher. NewFileReader does no fetch operation on the fetcher itself. The fetcher is only used in subsequent read operations. An error is only returned if the type of the superset is not either "file" or "bytes".

(fetcher blob.Fetcher)

Source from the content-addressed store, hash-verified

106// An error is only returned if the type of the superset is not either
107// "file" or "bytes".
108func (ss *superset) NewFileReader(fetcher blob.Fetcher) (*FileReader, error) {
109 if ss.Type != "file" && ss.Type != "bytes" {
110 return nil, fmt.Errorf("schema/filereader: Superset not of type \"file\" or \"bytes\"")
111 }
112 size := int64(ss.SumPartsSize())
113 fr := &FileReader{
114 fetcher: fetcher,
115 ss: ss,
116 size: size,
117 ssm: make(map[blob.Ref]*superset),
118 }
119 fr.SectionReader = io.NewSectionReader(fr, 0, size)
120 return fr, nil
121}
122
123// LoadAllChunks starts a process of loading all chunks of this file
124// as quickly as possible. The contents are immediately discarded, so

Callers 1

readerForOffsetMethod · 0.95

Calls 1

SumPartsSizeMethod · 0.95

Tested by

no test coverage detected