MCPcopy
hub / github.com/kopia/kopia / run

Method run

cli/command_index_epoch_list.go:25–86  ·  view source on GitHub ↗
(ctx context.Context, rep repo.DirectRepository)

Source from the content-addressed store, hash-verified

23}
24
25func (c *commandIndexEpochList) run(ctx context.Context, rep repo.DirectRepository) error {
26 emgr, ok, err := rep.ContentReader().EpochManager(ctx)
27 if err != nil {
28 return errors.Wrap(err, "epoch manager")
29 }
30
31 if !ok {
32 return errors.New("epoch manager is not active")
33 }
34
35 snap, err := emgr.Current(ctx)
36 if err != nil {
37 return errors.Wrap(err, "unable to determine current epoch")
38 }
39
40 c.out.printStdout("Current Epoch: %v\n", snap.WriteEpoch)
41
42 if est := snap.EpochStartTime[snap.WriteEpoch]; !est.IsZero() {
43 c.out.printStdout("Epoch Started %v\n", formatTimestamp(est))
44 }
45
46 firstNonRangeCompacted := 0
47 if len(snap.LongestRangeCheckpointSets) > 0 {
48 firstNonRangeCompacted = snap.LongestRangeCheckpointSets[len(snap.LongestRangeCheckpointSets)-1].MaxEpoch + 1
49 }
50
51 for e := snap.WriteEpoch; e >= firstNonRangeCompacted; e-- {
52 if uces := snap.UncompactedEpochSets[e]; len(uces) > 0 {
53 minTime := blob.MinTimestamp(uces)
54 maxTime := blob.MaxTimestamp(uces)
55
56 c.out.printStdout("%v %v ... %v, %v blobs, %v, span %v\n",
57 e,
58 formatTimestamp(minTime),
59 formatTimestamp(maxTime),
60 len(uces),
61 units.BytesString(blob.TotalLength(uces)),
62 maxTime.Sub(minTime).Round(time.Second),
63 )
64 }
65
66 if secs := snap.SingleEpochCompactionSets[e]; secs != nil {
67 c.out.printStdout("%v: %v single-epoch %v blobs, %v\n",
68 e,
69 formatTimestamp(secs[0].Timestamp),
70 len(secs),
71 units.BytesString(blob.TotalLength(secs)),
72 )
73 }
74 }
75
76 for _, cs := range snap.LongestRangeCheckpointSets {
77 c.out.printStdout("%v-%v: range, %v blobs, %v\n",
78 cs.MinEpoch,
79 cs.MaxEpoch,
80 len(cs.Blobs),
81 units.BytesString(blob.TotalLength(cs.Blobs)),
82 )

Callers

nothing calls this directly

Calls 10

MinTimestampFunction · 0.92
MaxTimestampFunction · 0.92
BytesStringFunction · 0.92
TotalLengthFunction · 0.92
formatTimestampFunction · 0.85
CurrentMethod · 0.80
printStdoutMethod · 0.80
SubMethod · 0.80
EpochManagerMethod · 0.65
ContentReaderMethod · 0.65

Tested by

no test coverage detected