mirror of
https://github.com/octoleo/restic.git
synced 2024-11-28 15:56:37 +00:00
Change bps and eta calculation to prevent overflow
This commit is contained in:
parent
6d0a6844e2
commit
a780462b80
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user