MCPcopy
hub / github.com/kopia/kopia / entryBits

Method entryBits

cli/command_snapshot_list.go:387–451  ·  view source on GitHub ↗
(ctx context.Context, m *snapshot.Manifest, ent fs.Entry, lastTotalFileSize int64)

Source from the content-addressed store, hash-verified

385}
386
387func (c *commandSnapshotList) entryBits(ctx context.Context, m *snapshot.Manifest, ent fs.Entry, lastTotalFileSize int64) (bits []string, col *color.Color) {
388 col = color.New() // default color
389
390 if m.IncompleteReason != "" {
391 bits = append(bits, "incomplete:"+m.IncompleteReason)
392 }
393
394 var summary *fs.DirectorySummary
395
396 if dws, ok := ent.(fs.DirectoryWithSummary); ok {
397 s, err := dws.Summary(ctx)
398 if err != nil {
399 log(ctx).Warnw("unable to get directory summary", "name", ent.Name(), "err", err)
400 }
401
402 summary = s
403 }
404
405 totalBytes := ent.Size()
406 if summary != nil {
407 totalBytes = summary.TotalFileSize
408 }
409
410 bits = append(bits,
411 maybeHumanReadableBytes(c.snapshotListShowHumanReadable, totalBytes),
412 ent.Mode().String())
413 if c.snapshotListShowOwner {
414 bits = append(bits,
415 fmt.Sprintf("uid:%v", ent.Owner().UserID),
416 fmt.Sprintf("gid:%v", ent.Owner().GroupID))
417 }
418
419 if c.snapshotListShowModTime {
420 bits = append(bits, fmt.Sprintf("modified:%v", formatTimestamp(ent.ModTime())))
421 }
422
423 if c.snapshotListShowItemID {
424 bits = append(bits, "manifest:"+string(m.ID))
425 }
426
427 if c.snapshotListShowDelta {
428 bits = append(bits, deltaBytes(ent.Size()-lastTotalFileSize))
429 }
430
431 if summary != nil {
432 bits = append(bits,
433 fmt.Sprintf("files:%v", summary.TotalFileCount),
434 fmt.Sprintf("dirs:%v", summary.TotalDirCount))
435 if summary.FatalErrorCount > 0 {
436 bits = append(bits, fmt.Sprintf("errors:%v", summary.FatalErrorCount))
437 col = errorColor
438 }
439 }
440
441 if u := m.StorageStats; u != nil {
442 bits = append(bits,
443 fmt.Sprintf("new-data:%v", units.BytesString(atomic.LoadInt64(&u.NewData.PackedContentBytes))),
444 fmt.Sprintf("new-files:%v", atomic.LoadInt32(&u.NewData.FileObjectCount)),

Callers 1

Calls 12

BytesStringFunction · 0.92
maybeHumanReadableBytesFunction · 0.85
formatTimestampFunction · 0.85
deltaBytesFunction · 0.85
SummaryMethod · 0.65
NameMethod · 0.65
OwnerMethod · 0.65
SizeMethod · 0.45
StringMethod · 0.45
ModeMethod · 0.45
ModTimeMethod · 0.45

Tested by

no test coverage detected