MCPcopy
hub / github.com/google/go-containerregistry / Stat

Method Stat

pkg/registry/blobs_disk.go:38–55  ·  view source on GitHub ↗
(_ context.Context, _ string, h v1.Hash)

Source from the content-addressed store, hash-verified

36}
37
38func (m *diskHandler) Stat(_ context.Context, _ string, h v1.Hash) (int64, error) {
39 f, err := os.Open(m.blobHashPath(h))
40 if errors.Is(err, os.ErrNotExist) {
41 return 0, ErrNotFound
42 } else if err != nil {
43 return 0, err
44 }
45 defer f.Close()
46
47 got, size, err := v1.SHA256(f)
48 if err != nil {
49 return 0, err
50 }
51 if got != h {
52 return 0, fmt.Errorf("%w: blob %s has digest %s", ErrNotFound, h, got)
53 }
54 return size, nil
55}
56
57func (m *diskHandler) Get(_ context.Context, _ string, h v1.Hash) (io.ReadCloser, error) {
58 return os.Open(m.blobHashPath(h))

Callers

nothing calls this directly

Calls 4

blobHashPathMethod · 0.95
SHA256Function · 0.92
CloseMethod · 0.65
IsMethod · 0.45

Tested by

no test coverage detected