MCPcopy
hub / github.com/containerd/containerd / Delete

Method Delete

core/metadata/content.go:204–243  ·  view source on GitHub ↗
(ctx context.Context, dgst digest.Digest)

Source from the content-addressed store, hash-verified

202}
203
204func (cs *contentStore) Delete(ctx context.Context, dgst digest.Digest) error {
205 ns, err := namespaces.NamespaceRequired(ctx)
206 if err != nil {
207 return err
208 }
209
210 cs.l.RLock()
211 defer cs.l.RUnlock()
212
213 if err := update(ctx, cs.db, func(tx *bolt.Tx) error {
214 bkt := getBlobBucket(tx, ns, dgst)
215 if bkt == nil {
216 return fmt.Errorf("content digest %v: %w", dgst, errdefs.ErrNotFound)
217 }
218
219 if err := getBlobsBucket(tx, ns).DeleteBucket([]byte(dgst.String())); err != nil {
220 return err
221 }
222 if err := removeContentLease(ctx, tx, dgst); err != nil {
223 return err
224 }
225
226 // Mark content store as dirty for triggering garbage collection
227 cs.db.dirty.Add(1)
228 cs.db.dirtyCS = true
229
230 return nil
231 }); err != nil {
232 return err
233 }
234
235 if publisher := cs.db.Publisher(ctx); publisher != nil {
236 if err := publisher.Publish(ctx, "/content/delete", &eventstypes.ContentDelete{
237 Digest: dgst.String(),
238 }); err != nil {
239 return err
240 }
241 }
242 return nil
243}
244
245func (cs *contentStore) ListStatuses(ctx context.Context, fs ...string) ([]content.Status, error) {
246 ns, err := namespaces.NamespaceRequired(ctx)

Callers

nothing calls this directly

Calls 9

NamespaceRequiredFunction · 0.92
updateFunction · 0.85
getBlobBucketFunction · 0.85
getBlobsBucketFunction · 0.85
removeContentLeaseFunction · 0.85
PublisherMethod · 0.80
AddMethod · 0.65
PublishMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected