(ctx context.Context, rep repo.DirectRepository)
| 40 | } |
| 41 | |
| 42 | func (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 | |
| 90 | func (c *commandContentList) outputLong(b content.Info) { |
| 91 | c.out.printStdout("%v %v %v %v %v+%v%v %v\n", |
nothing calls this directly
no test coverage detected