MCPcopy
hub / github.com/kopia/kopia / snapshotDeleteSources

Method snapshotDeleteSources

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

Source from the content-addressed store, hash-verified

51}
52
53func (c *commandSnapshotDelete) snapshotDeleteSources(ctx context.Context, rep repo.RepositoryWriter) error {
54 for _, source := range c.snapshotDeleteIDs {
55 si, err := snapshot.ParseSourceInfo(source, rep.ClientOptions().Hostname, rep.ClientOptions().Username)
56 if err != nil {
57 return errors.Wrapf(err, "invalid source '%s'", source)
58 }
59
60 manifestIDs, err := snapshot.ListSnapshotManifests(ctx, rep, &si, nil)
61 if err != nil {
62 return errors.Wrapf(err, "error listing manifests for %v", si)
63 }
64
65 manifests, err := snapshot.LoadSnapshots(ctx, rep, manifestIDs)
66 if err != nil {
67 return errors.Wrapf(err, "error loading manifests for %v", si)
68 }
69
70 if len(manifests) == 0 {
71 return errors.Errorf("no snapshots for source %v", si)
72 }
73
74 for _, m := range manifests {
75 if err := c.deleteSnapshot(ctx, rep, m); err != nil {
76 return errors.Wrap(err, "error deleting")
77 }
78 }
79 }
80
81 return nil
82}
83
84func (c *commandSnapshotDelete) deleteSnapshot(ctx context.Context, rep repo.RepositoryWriter, m *snapshot.Manifest) error {
85 desc := fmt.Sprintf("snapshot %v of %v at %v", m.ID, m.Source, formatTimestamp(m.StartTime.ToTime()))

Callers 1

runMethod · 0.95

Calls 6

deleteSnapshotMethod · 0.95
ParseSourceInfoFunction · 0.92
ListSnapshotManifestsFunction · 0.92
LoadSnapshotsFunction · 0.92
ErrorfMethod · 0.80
ClientOptionsMethod · 0.65

Tested by

no test coverage detected