NewLabeledStore returns a new content store using the provided label store Note: content stores which are used underneath a metadata store may not require labels and should use `NewStore`. `NewLabeledStore` is primarily useful for tests or standalone implementations.
(root string, ls LabelStore)
| 86 | // require labels and should use `NewStore`. `NewLabeledStore` is primarily |
| 87 | // useful for tests or standalone implementations. |
| 88 | func NewLabeledStore(root string, ls LabelStore) (content.Store, error) { |
| 89 | if _, err := os.Stat(root); err != nil { |
| 90 | if !errors.Is(err, fs.ErrNotExist) { |
| 91 | return nil, fmt.Errorf("failed to stat %q: %w", root, err) |
| 92 | } |
| 93 | if err := os.MkdirAll(root, 0755); err != nil { |
| 94 | return nil, fmt.Errorf("failed to mkdir %q: %w", root, err) |
| 95 | } |
| 96 | } |
| 97 | supported, err := fsverity.IsSupported(root) |
| 98 | if err != nil { |
| 99 | log.L.WithError(err).WithField("path", root).Warnf("failed check for fsverity support") |
| 100 | } |
| 101 | s := &store{ |
| 102 | root: root, |
| 103 | ls: ls, |
| 104 | integritySupported: supported, |
| 105 | locks: map[string]*lock{}, |
| 106 | } |
| 107 | s.ensureIngestRootOnce = sync.OnceValue(s.ensureIngestRoot) |
| 108 | return s, nil |
| 109 | } |
| 110 | |
| 111 | func (s *store) Info(ctx context.Context, dgst digest.Digest) (content.Info, error) { |
| 112 | p, err := s.blobPath(dgst) |
searching dependent graphs…