MCPcopy Create free account
hub / github.com/containers/image / GetBlob

Method GetBlob

pkg/blobcache/src.go:82–110  ·  view source on GitHub ↗
(ctx context.Context, blobinfo types.BlobInfo, cache types.BlobInfoCache)

Source from the content-addressed store, hash-verified

80}
81
82func (s *blobCacheSource) GetBlob(ctx context.Context, blobinfo types.BlobInfo, cache types.BlobInfoCache) (io.ReadCloser, int64, error) {
83 blobPath, size, _, err := s.reference.findBlob(blobinfo)
84 if err != nil {
85 return nil, -1, err
86 }
87 if blobPath != "" {
88 f, err := os.Open(blobPath)
89 if err == nil {
90 s.mu.Lock()
91 s.cacheHits++
92 s.mu.Unlock()
93 return f, size, nil
94 }
95 if !os.IsNotExist(err) {
96 s.mu.Lock()
97 s.cacheErrors++
98 s.mu.Unlock()
99 return nil, -1, fmt.Errorf("checking for cache: %w", err)
100 }
101 }
102 s.mu.Lock()
103 s.cacheMisses++
104 s.mu.Unlock()
105 rc, size, err := s.source.GetBlob(ctx, blobinfo, cache)
106 if err != nil {
107 return rc, size, fmt.Errorf("error reading blob from source image %q: %w", transports.ImageName(s.reference), err)
108 }
109 return rc, size, nil
110}
111
112// GetSignaturesWithFormat returns the image's signatures. It may use a remote (= slow) service.
113// If instanceDigest is not nil, it contains a digest of the specific manifest instance to retrieve signatures for

Callers

nothing calls this directly

Calls 4

ImageNameFunction · 0.92
findBlobMethod · 0.80
OpenMethod · 0.65
GetBlobMethod · 0.65

Tested by

no test coverage detected