diff --git a/cmd/khepri/cmd_backup.go b/cmd/khepri/cmd_backup.go index 739dd67a4..a7f329dda 100644 --- a/cmd/khepri/cmd_backup.go +++ b/cmd/khepri/cmd_backup.go @@ -108,9 +108,9 @@ func commandBackup(be backend.Server, key *khepri.Key, args []string) error { go func(ch <-chan khepri.Stats) { - status := func(d time.Duration) { + status := func(sec uint64) { fmt.Printf("\x1b[2K\r[%s] %3.2f%% %s/s %s / %s ETA %s", - format_duration(uint64(d/time.Second)), + format_duration(sec), float64(stats.Bytes)/float64(arch.Stats.Bytes)*100, format_bytes(bps), format_bytes(stats.Bytes), format_bytes(arch.Stats.Bytes), @@ -129,16 +129,16 @@ func commandBackup(be backend.Server, key *khepri.Key, args []string) error { stats.Other += s.Other stats.Bytes += s.Bytes - status(time.Since(start)) + status(uint64(time.Since(start) / time.Second)) case <-ticker.C: - d := time.Since(start) - bps = stats.Bytes * uint64(time.Second) / uint64(d) + sec := uint64(time.Since(start) / time.Second) + bps = stats.Bytes / sec if bps > 0 { eta = (arch.Stats.Bytes - stats.Bytes) / bps } - status(d) + status(sec) } } }(ch)