From e71edd557709ec663c14d1033f464eb8f4fe69a2 Mon Sep 17 00:00:00 2001 From: Gary Kim Date: Tue, 28 Jan 2020 17:54:25 +0800 Subject: [PATCH] cmd: always print elapsed time to tenth place seconds in progress Before this change, the elapsed time shown with the --progress flag would not print ".0s" so the elapsed time. This change will make it so that the line width is kept a bit more consistent by always printing to a fixed-point. This does change the displayed value when the elapsed time is less than 1s, in which it used to be that the value would be shown in ms or smaller units. Signed-off-by: Gary Kim --- fs/accounting/stats.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/accounting/stats.go b/fs/accounting/stats.go index 0ed536b14..993afdcba 100644 --- a/fs/accounting/stats.go +++ b/fs/accounting/stats.go @@ -250,11 +250,11 @@ func (s *StatsInfo) String() string { dt := s.totalDuration() dtSeconds := dt.Seconds() + dtSecondsOnly := dt.Truncate(time.Second/10) % time.Minute speed := 0.0 if dt > 0 { speed = float64(s.bytes) / dtSeconds } - dtRounded := dt - (dt % (time.Second / 10)) displaySpeed := speed if fs.Config.DataRateUnit == "bits" { @@ -329,7 +329,7 @@ func (s *StatsInfo) String() string { _, _ = fmt.Fprintf(buf, "Transferred: %10d / %d, %s\n", s.transfers, totalTransfer, percent(s.transfers, totalTransfer)) } - _, _ = fmt.Fprintf(buf, "Elapsed time: %10v\n", dtRounded) + _, _ = fmt.Fprintf(buf, "Elapsed time: %10ss\n", strings.TrimRight(dt.Truncate(time.Minute).String(), "0s")+fmt.Sprintf("%.1f", dtSecondsOnly.Seconds())) } // checking and transferring have their own locking so unlock