(ctx context.Context, e fs.Entry, prefix, indent string)
| 89 | } |
| 90 | |
| 91 | func (c *commandList) printDirectoryEntry(ctx context.Context, e fs.Entry, prefix, indent string) error { |
| 92 | hoid, ok := e.(object.HasObjectID) |
| 93 | if !ok { |
| 94 | return errors.New("entry without object ID") |
| 95 | } |
| 96 | |
| 97 | objectID := hoid.ObjectID() |
| 98 | oid := objectID.String() |
| 99 | col := defaultColor |
| 100 | |
| 101 | var ( |
| 102 | errorSummary string |
| 103 | info string |
| 104 | ) |
| 105 | |
| 106 | if dws, ok := e.(fs.DirectoryWithSummary); ok && c.errorSummary { |
| 107 | if ds, _ := dws.Summary(ctx); ds != nil && ds.FatalErrorCount > 0 { |
| 108 | errorSummary = fmt.Sprintf(" (%v errors)", ds.FatalErrorCount) |
| 109 | col = errorColor |
| 110 | } |
| 111 | } |
| 112 | |
| 113 | switch { |
| 114 | case c.long: |
| 115 | info = fmt.Sprintf( |
| 116 | "%v %12s %v %-34v %v%v", |
| 117 | e.Mode(), |
| 118 | maybeHumanReadableBytes(c.humanReadable, e.Size()), |
| 119 | formatTimestamp(e.ModTime().Local()), |
| 120 | oid, |
| 121 | c.nameToDisplay(prefix, e), |
| 122 | errorSummary, |
| 123 | ) |
| 124 | case c.showOID: |
| 125 | info = fmt.Sprintf("%-34v %v%v", oid, c.nameToDisplay(prefix, e), errorSummary) |
| 126 | |
| 127 | default: |
| 128 | info = fmt.Sprintf("%v%v", c.nameToDisplay(prefix, e), errorSummary) |
| 129 | } |
| 130 | |
| 131 | col.Fprintln(c.out.stdout(), info) //nolint:errcheck |
| 132 | |
| 133 | if c.recursive { |
| 134 | if subdir, ok := e.(fs.Directory); ok { |
| 135 | if listerr := c.listDirectory(ctx, subdir, prefix+e.Name()+"/", indent+" "); listerr != nil { |
| 136 | return listerr |
| 137 | } |
| 138 | } |
| 139 | } |
| 140 | |
| 141 | return nil |
| 142 | } |
| 143 | |
| 144 | func (c *commandList) nameToDisplay(prefix string, e fs.Entry) string { |
| 145 | suffix := "" |
no test coverage detected