From 7e602dbf393b793ac804b219cc5dadc3692fb363 Mon Sep 17 00:00:00 2001 From: anuar45 Date: Thu, 21 Nov 2019 12:15:47 +0100 Subject: [PATCH] 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. --- fs/accounting/stats.go | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/fs/accounting/stats.go b/fs/accounting/stats.go index 35c8d7db4..a2e44fb60 100644 --- a/fs/accounting/stats.go +++ b/fs/accounting/stats.go @@ -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, fs.SizeSuffix(s.bytes), fs.SizeSuffix(totalSize).Unit("Bytes"), @@ -313,16 +313,23 @@ func (s *StatsInfo) String() string { errorDetails = " (no need to retry)" } - _, _ = fmt.Fprintf(buf, ` -Errors: %10d%s -Checks: %10d / %d, %s -Transferred: %10d / %d, %s -Elapsed time: %10v -`, - s.errors, errorDetails, - s.checks, totalChecks, percent(s.checks, totalChecks), - s.transfers, totalTransfer, percent(s.transfers, totalTransfer), - dtRounded) + // Add only non zero stats + if s.errors != 0 { + _, _ = fmt.Fprintf(buf, "Errors: %10d%s\n", + s.errors, errorDetails) + } + if s.checks != 0 || totalChecks != 0 { + _, _ = fmt.Fprintf(buf, "Checks: %10d / %d, %s\n", + s.errors, totalChecks, percent(s.checks, totalChecks)) + } + 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