(ctx context.Context, rep repo.RepositoryWriter)
| 29 | } |
| 30 | |
| 31 | func (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 | |
| 53 | func (c *commandSnapshotDelete) snapshotDeleteSources(ctx context.Context, rep repo.RepositoryWriter) error { |
| 54 | for _, source := range c.snapshotDeleteIDs { |
nothing calls this directly
no test coverage detected