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

Method run

cli/command_index_list.go:31–70  ·  view source on GitHub ↗
(ctx context.Context, rep repo.DirectRepository)

Source from the content-addressed store, hash-verified

29}
30
31func (c *commandIndexList) run(ctx context.Context, rep repo.DirectRepository) error {
32 var jl jsonList
33
34 jl.begin(&c.jo)
35 defer jl.end()
36
37 blks, err := rep.IndexBlobs(ctx, c.blockIndexListIncludeSuperseded)
38 if err != nil {
39 return errors.Wrap(err, "error listing index blobs")
40 }
41
42 switch c.blockIndexListSort {
43 case "time":
44 sort.Slice(blks, func(i, j int) bool {
45 return blks[i].Timestamp.Before(blks[j].Timestamp)
46 })
47 case "size":
48 sort.Slice(blks, func(i, j int) bool {
49 return blks[i].Length < blks[j].Length
50 })
51 case "name":
52 sort.Slice(blks, func(i, j int) bool {
53 return blks[i].BlobID < blks[j].BlobID
54 })
55 }
56
57 for _, b := range blks {
58 if c.jo.jsonOutput {
59 jl.emit(b)
60 } else {
61 c.out.printStdout("%-60v %10v %v %v\n", b.BlobID, b.Length, formatTimestampPrecise(b.Timestamp), b.Superseded)
62 }
63 }
64
65 if c.blockIndexListSummary && !c.jo.jsonOutput {
66 c.out.printStdout("total %v indexes\n", len(blks))
67 }
68
69 return nil
70}

Callers

nothing calls this directly

Calls 7

beginMethod · 0.95
endMethod · 0.95
emitMethod · 0.95
formatTimestampPreciseFunction · 0.85
printStdoutMethod · 0.80
IndexBlobsMethod · 0.65
BeforeMethod · 0.45

Tested by

no test coverage detected