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

Method run

cli/command_content_list.go:42–88  ·  view source on GitHub ↗
(ctx context.Context, rep repo.DirectRepository)

Source from the content-addressed store, hash-verified

40}
41
42func (c *commandContentList) run(ctx context.Context, rep repo.DirectRepository) error {
43 var jl jsonList
44
45 jl.begin(&c.jo)
46 defer jl.end()
47
48 var totalSize stats.CountSum
49
50 err := rep.ContentReader().IterateContents(
51 ctx,
52 content.IterateOptions{
53 Range: c.contentRange.contentIDRange(),
54 IncludeDeleted: c.includeDeleted || c.deletedOnly,
55 },
56 func(b content.Info) error {
57 if c.deletedOnly && !b.Deleted {
58 return nil
59 }
60
61 totalSize.Add(int64(b.PackedLength))
62
63 switch {
64 case c.jo.jsonOutput:
65 jl.emit(b)
66 case c.compression:
67 c.outputCompressed(b)
68 case c.long:
69 c.outputLong(b)
70 default:
71 c.out.printStdout("%v\n", b.ContentID)
72 }
73
74 return nil
75 })
76 if err != nil {
77 return errors.Wrap(err, "error iterating")
78 }
79
80 if c.summary {
81 count, sz := totalSize.Approximate()
82 c.out.printStdout("Total: %v contents, %v total size\n",
83 maybeHumanReadableCount(c.human, int64(count)),
84 maybeHumanReadableBytes(c.human, sz))
85 }
86
87 return nil
88}
89
90func (c *commandContentList) outputLong(b content.Info) {
91 c.out.printStdout("%v %v %v %v %v+%v%v %v\n",

Callers

nothing calls this directly

Calls 13

beginMethod · 0.95
endMethod · 0.95
AddMethod · 0.95
emitMethod · 0.95
outputCompressedMethod · 0.95
outputLongMethod · 0.95
ApproximateMethod · 0.95
maybeHumanReadableCountFunction · 0.85
maybeHumanReadableBytesFunction · 0.85
contentIDRangeMethod · 0.80
printStdoutMethod · 0.80
IterateContentsMethod · 0.65

Tested by

no test coverage detected