mirror of
https://github.com/octoleo/restic.git
synced 2024-11-11 07:41:03 +00:00
37 lines
695 B
Go
37 lines
695 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"time"
|
|
|
|
"github.com/restic/restic/internal/restic"
|
|
)
|
|
|
|
// newProgressMax returns a progress that counts blobs.
|
|
func newProgressMax(show bool, max uint64, description string) *restic.Progress {
|
|
if !show {
|
|
return nil
|
|
}
|
|
|
|
p := restic.NewProgress()
|
|
|
|
p.OnUpdate = func(s restic.Stat, d time.Duration, ticker bool) {
|
|
status := fmt.Sprintf("[%s] %s %d / %d %s",
|
|
formatDuration(d),
|
|
formatPercent(s.Blobs, max),
|
|
s.Blobs, max, description)
|
|
|
|
if w := stdoutTerminalWidth(); w > 0 {
|
|
status = shortenStatus(w, status)
|
|
}
|
|
|
|
PrintProgress("%s", status)
|
|
}
|
|
|
|
p.OnDone = func(s restic.Stat, d time.Duration, ticker bool) {
|
|
fmt.Printf("\n")
|
|
}
|
|
|
|
return p
|
|
}
|