mirror of
https://github.com/restic/restic.git
synced 2026-11-18 22:58:07 +00:00
progress/counter: Support updating the progress bar maximum
This commit is contained in:
1 parent
eda8c67616
commit
505f8a2229
3 files changed
+47
-13
No files matched your search
@@ -33,11 +33,14 @@ func newProgressMax(show bool, max uint64, description string) *progress.Counter
|
||||
}
|
||||
interval := calculateProgressInterval()
|
||||
|
||||
return progress.New(interval, func(v uint64, d time.Duration, final bool) {
|
||||
status := fmt.Sprintf("[%s] %s %d / %d %s",
|
||||
formatDuration(d),
|
||||
formatPercent(v, max),
|
||||
v, max, description)
|
||||
return progress.New(interval, max, func(v uint64, max uint64, d time.Duration, final bool) {
|
||||
var status string
|
||||
if max == 0 {
|
||||
status = fmt.Sprintf("[%s] %d %s", formatDuration(d), v, description)
|
||||
} else {
|
||||
status = fmt.Sprintf("[%s] %s %d / %d %s",
|
||||
formatDuration(d), formatPercent(v, max), v, max, description)
|
||||
}
|
||||
|
||||
if w := stdoutTerminalWidth(); w > 0 {
|
||||
status = shortenStatus(w, status)
|
||||
|
||||
Reference in new issue
Block a user