2
2
mirror of https://github.com/octoleo/restic.git synced 2024-05-31 16:10:49 +00:00

Fix ETA display

Closes #111
This commit is contained in:
Alexander Neumann 2015-03-16 20:20:53 +01:00
parent d9fbf9ad02
commit 489cc654e8

View File

@ -105,15 +105,22 @@ func newArchiveProgress(todo restic.Stat) *restic.Progress {
sec := uint64(d / time.Second)
if todo.Bytes > 0 && sec > 0 && ticker {
bps = s.Bytes / sec
if bps > 0 {
if s.Bytes >= todo.Bytes {
eta = 0
} else if bps > 0 {
eta = (todo.Bytes - s.Bytes) / bps
}
}
itemsDone := s.Files + s.Dirs
percent := float64(s.Bytes) / float64(todo.Bytes) * 100
if percent > 100 {
percent = 100
}
fmt.Printf("\x1b[2K\r[%s] %3.2f%% %s/s %s / %s %d / %d items ETA %s",
format_duration(d),
float64(s.Bytes)/float64(todo.Bytes)*100,
percent,
format_bytes(bps),
format_bytes(s.Bytes), format_bytes(todo.Bytes),
itemsDone, itemsTodo,