MCPcopy Index your code
hub / github.com/kopia/kopia / run

Method run

cli/command_snapshot_delete.go:31–51  ·  view source on GitHub ↗
(ctx context.Context, rep repo.RepositoryWriter)

Source from the content-addressed store, hash-verified

29}
30
31func (c *commandSnapshotDelete) run(ctx context.Context, rep repo.RepositoryWriter) error {
32 if c.snapshotDeleteAllSnapshotsForSource {
33 return c.snapshotDeleteSources(ctx, rep)
34 }
35
36 for _, id := range c.snapshotDeleteIDs {
37 m, err := snapshot.LoadSnapshot(ctx, rep, manifest.ID(id))
38 if err == nil {
39 // snapshot found by manifest ID, delete it directly.
40 if err = c.deleteSnapshot(ctx, rep, m); err != nil {
41 return errors.Wrapf(err, "error deleting %v", id)
42 }
43 } else if !errors.Is(err, snapshot.ErrSnapshotNotFound) {
44 return errors.Wrapf(err, "error loading snapshot %v", id)
45 } else if err := c.deleteSnapshotsByRootObjectID(ctx, rep, id); err != nil {
46 return errors.Wrapf(err, "error deleting snapshots by root ID %v", id)
47 }
48 }
49
50 return nil
51}
52
53func (c *commandSnapshotDelete) snapshotDeleteSources(ctx context.Context, rep repo.RepositoryWriter) error {
54 for _, source := range c.snapshotDeleteIDs {

Callers

nothing calls this directly

Calls 5

snapshotDeleteSourcesMethod · 0.95
deleteSnapshotMethod · 0.95
LoadSnapshotFunction · 0.92
IDTypeAlias · 0.92

Tested by

no test coverage detected