(ctx context.Context, fileRef blob.Ref)
| 235 | } |
| 236 | |
| 237 | func (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 | |
| 259 | func (ih *ImageHandler) scaleImage(ctx context.Context, fileRef blob.Ref) (*formatAndImage, error) { |
| 260 | fr, err := ih.newFileReader(ctx, fileRef) |
no test coverage detected