MCPcopy
hub / github.com/perkeep/perkeep / newFileReader

Method newFileReader

pkg/server/image.go:237–257  ·  view source on GitHub ↗
(ctx context.Context, fileRef blob.Ref)

Source from the content-addressed store, hash-verified

235}
236
237func (ih *ImageHandler) newFileReader(ctx context.Context, fileRef blob.Ref) (io.ReadCloser, error) {
238 fi, ok := fileInfoPacked(ctx, ih.Search, ih.Fetcher, nil, fileRef)
239 if debugPack {
240 log.Printf("pkg/server/image.go: fileInfoPacked: ok=%v, %+v", ok, fi)
241 }
242 if ok {
243 // This would be less gross if fileInfoPacked just
244 // returned an io.ReadCloser, but then the download
245 // handler would need more invasive changes for
246 // ServeContent. So tolerate this for now.
247 return struct {
248 io.Reader
249 io.Closer
250 }{
251 fi.rs,
252 types.CloseFunc(fi.close),
253 }, nil
254 }
255 // Default path, not going through blobpacked's fast path:
256 return schema.NewFileReader(ctx, ih.Fetcher, fileRef)
257}
258
259func (ih *ImageHandler) scaleImage(ctx context.Context, fileRef blob.Ref) (*formatAndImage, error) {
260 fr, err := ih.newFileReader(ctx, fileRef)

Callers 1

scaleImageMethod · 0.95

Calls 3

NewFileReaderFunction · 0.92
fileInfoPackedFunction · 0.85
PrintfMethod · 0.80

Tested by

no test coverage detected