1
mirror of https://github.com/rclone/rclone synced 2024-12-24 15:43:45 +01:00

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 <gary@garykim.dev>
This commit is contained in:
Gary Kim 2020-01-28 17:54:25 +08:00 committed by Nick Craig-Wood
parent 27a34dd183
commit e71edd5577

View File

@ -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