MCPcopy
hub / github.com/kopia/kopia / pinSnapshotsByRootObjectID

Method pinSnapshotsByRootObjectID

cli/command_snapshot_pin.go:49–71  ·  view source on GitHub ↗
(ctx context.Context, rep repo.RepositoryWriter, rootID string)

Source from the content-addressed store, hash-verified

47}
48
49func (c *commandSnapshotPin) pinSnapshotsByRootObjectID(ctx context.Context, rep repo.RepositoryWriter, rootID string) error {
50 rootOID, err := object.ParseID(rootID)
51 if err != nil {
52 return errors.Wrap(err, "unable to parse object ID")
53 }
54
55 manifests, err := snapshot.FindSnapshotsByRootObjectID(ctx, rep, rootOID)
56 if err != nil {
57 return errors.Wrapf(err, "unable to find snapshots by root %v", rootID)
58 }
59
60 if len(manifests) == 0 {
61 return errors.Errorf("no snapshots matched %v", rootID)
62 }
63
64 for _, m := range manifests {
65 if err := c.pinSnapshot(ctx, rep, m); err != nil {
66 return errors.Wrap(err, "error pinning")
67 }
68 }
69
70 return nil
71}
72
73func (c *commandSnapshotPin) pinSnapshot(ctx context.Context, rep repo.RepositoryWriter, m *snapshot.Manifest) error {
74 if !m.UpdatePins(c.addPins, c.removePins) {

Callers 1

runMethod · 0.95

Calls 4

pinSnapshotMethod · 0.95
ParseIDFunction · 0.92
ErrorfMethod · 0.80

Tested by

no test coverage detected