MCPcopy
hub / github.com/kopia/kopia / showContentWithFlags

Function showContentWithFlags

cli/show_utils.go:26–55  ·  view source on GitHub ↗

nolint:gochecknoglobals

(w io.Writer, rd io.Reader, unzip, indentJSON bool)

Source from the content-addressed store, hash-verified

24var timeZone = "local" //nolint:gochecknoglobals
25
26func showContentWithFlags(w io.Writer, rd io.Reader, unzip, indentJSON bool) error {
27 if unzip {
28 gz, err := gzip.NewReader(rd)
29 if err != nil {
30 return errors.Wrap(err, "unable to open gzip stream")
31 }
32
33 rd = gz
34 }
35
36 var buf1, buf2 bytes.Buffer
37
38 if indentJSON {
39 if err := iocopy.JustCopy(&buf1, rd); err != nil {
40 return errors.Wrap(err, "error copying data")
41 }
42
43 if err := json.Indent(&buf2, buf1.Bytes(), "", " "); err != nil {
44 return errors.Wrap(err, "errors indenting JSON")
45 }
46
47 rd = io.NopCloser(&buf2)
48 }
49
50 if err := iocopy.JustCopy(w, rd); err != nil {
51 return errors.Wrap(err, "error copying data")
52 }
53
54 return nil
55}
56
57func maybeHumanReadableBytes[I constraints.Integer](enable bool, value I) string {
58 if enable {

Callers 3

contentShowMethod · 0.85
runMethod · 0.85
showManifestItemsMethod · 0.85

Calls 2

JustCopyFunction · 0.92
BytesMethod · 0.45

Tested by

no test coverage detected