(ctx context.Context, rep repo.DirectRepository)
| 33 | } |
| 34 | |
| 35 | func (c *commandContentStats) run(ctx context.Context, rep repo.DirectRepository) error { |
| 36 | var ( |
| 37 | sizeThreshold uint32 = 10 |
| 38 | sizeBuckets []uint32 |
| 39 | ) |
| 40 | |
| 41 | for range 8 { |
| 42 | sizeBuckets = append(sizeBuckets, sizeThreshold) |
| 43 | sizeThreshold *= 10 |
| 44 | } |
| 45 | |
| 46 | grandTotal, byCompressionTotal, countMap, totalSizeOfContentsUnder, err := c.calculateStats(ctx, rep, sizeBuckets) |
| 47 | if err != nil { |
| 48 | return errors.Wrap(err, "error calculating totals") |
| 49 | } |
| 50 | |
| 51 | sizeToString := units.BytesString[int64] |
| 52 | if c.raw { |
| 53 | sizeToString = func(l int64) string { |
| 54 | return strconv.FormatInt(l, 10) |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | c.out.printStdout("Count: %v\n", grandTotal.count) |
| 59 | c.out.printStdout("Total Bytes: %v\n", sizeToString(grandTotal.originalSize)) |
| 60 | |
| 61 | if grandTotal.packedSize < grandTotal.originalSize { |
| 62 | c.out.printStdout( |
| 63 | "Total Packed: %v (compression %v)\n", |
| 64 | sizeToString(grandTotal.packedSize), |
| 65 | formatCompressionPercentage(grandTotal.originalSize, grandTotal.packedSize)) |
| 66 | } |
| 67 | |
| 68 | if len(byCompressionTotal) > 1 { |
| 69 | c.out.printStdout("By Method:\n") |
| 70 | |
| 71 | if bct := byCompressionTotal[content.NoCompression]; bct != nil { |
| 72 | c.out.printStdout(" %-22v count: %v size: %v\n", "(uncompressed)", bct.count, sizeToString(bct.originalSize)) |
| 73 | } |
| 74 | |
| 75 | for hdrID, bct := range byCompressionTotal { |
| 76 | cname := compression.HeaderIDToName[hdrID] |
| 77 | if cname == "" { |
| 78 | continue |
| 79 | } |
| 80 | |
| 81 | c.out.printStdout(" %-22v count: %v size: %v packed: %v compression: %v\n", |
| 82 | cname, bct.count, |
| 83 | sizeToString(bct.originalSize), |
| 84 | sizeToString(bct.packedSize), |
| 85 | formatCompressionPercentage(bct.originalSize, bct.packedSize)) |
| 86 | } |
| 87 | } |
| 88 | |
| 89 | if grandTotal.count == 0 { |
| 90 | return nil |
| 91 | } |
| 92 |
nothing calls this directly
no test coverage detected