stats: show deletes in stats and hide zero stats

This shows deletes in the stats.  It also doesn't show zero stats
in order not to make the stats block too long.
This commit is contained in:
anuar45 2019-11-21 12:15:47 +01:00 committed by Nick Craig-Wood
parent e14d968f8d
commit 7e602dbf39

View File

@ -292,7 +292,7 @@ func (s *StatsInfo) String() string {
} }
} }
_, _ = fmt.Fprintf(buf, "%s%10s / %s, %s, %s, ETA %s%s", _, _ = fmt.Fprintf(buf, "%s%10s / %s, %s, %s, ETA %s%s\n",
dateString, dateString,
fs.SizeSuffix(s.bytes), fs.SizeSuffix(s.bytes),
fs.SizeSuffix(totalSize).Unit("Bytes"), fs.SizeSuffix(totalSize).Unit("Bytes"),
@ -313,16 +313,23 @@ func (s *StatsInfo) String() string {
errorDetails = " (no need to retry)" errorDetails = " (no need to retry)"
} }
_, _ = fmt.Fprintf(buf, ` // Add only non zero stats
Errors: %10d%s if s.errors != 0 {
Checks: %10d / %d, %s _, _ = fmt.Fprintf(buf, "Errors: %10d%s\n",
Transferred: %10d / %d, %s s.errors, errorDetails)
Elapsed time: %10v }
`, if s.checks != 0 || totalChecks != 0 {
s.errors, errorDetails, _, _ = fmt.Fprintf(buf, "Checks: %10d / %d, %s\n",
s.checks, totalChecks, percent(s.checks, totalChecks), s.errors, totalChecks, percent(s.checks, totalChecks))
s.transfers, totalTransfer, percent(s.transfers, totalTransfer), }
dtRounded) if s.deletes != 0 {
_, _ = fmt.Fprintf(buf, "Deleted: %10d\n", s.deletes)
}
if s.transfers != 0 || totalTransfer != 0 {
_, _ = fmt.Fprintf(buf, "Transferred: %10d / %d, %s\n",
s.transfers, totalTransfer, percent(s.transfers, totalTransfer))
}
_, _ = fmt.Fprintf(buf, "Elapsed time: %10v\n", dtRounded)
} }
// checking and transferring have their own locking so unlock // checking and transferring have their own locking so unlock