mirror of
https://github.com/restic/restic.git
synced 2025-12-11 18:47:50 +00:00
cleanup progress bar creation special cases
This commit is contained in:
@@ -87,7 +87,8 @@ func runRecover(ctx context.Context, gopts GlobalOptions, term *termstatus.Termi
|
||||
}
|
||||
|
||||
printer.P("load %d trees\n", len(trees))
|
||||
bar = newTerminalProgressMax(!gopts.Quiet, uint64(len(trees)), "trees loaded", term)
|
||||
bar = printer.NewCounter("trees loaded")
|
||||
bar.SetMax(uint64(len(trees)))
|
||||
for id := range trees {
|
||||
tree, err := restic.LoadTree(ctx, repo, id)
|
||||
if ctx.Err() != nil {
|
||||
|
||||
@@ -10,7 +10,6 @@ import (
|
||||
"github.com/restic/restic/internal/filter"
|
||||
"github.com/restic/restic/internal/restic"
|
||||
"github.com/restic/restic/internal/restorer"
|
||||
"github.com/restic/restic/internal/terminal"
|
||||
restoreui "github.com/restic/restic/internal/ui/restore"
|
||||
"github.com/restic/restic/internal/ui/termstatus"
|
||||
|
||||
@@ -260,7 +259,7 @@ func runRestore(ctx context.Context, opts RestoreOptions, gopts GlobalOptions,
|
||||
}
|
||||
var count int
|
||||
t0 := time.Now()
|
||||
bar := newTerminalProgressMax(!gopts.Quiet && !gopts.JSON && terminal.StdoutIsTerminal(), 0, "files verified", term)
|
||||
bar := msg.NewCounterTerminalOnly("files verified")
|
||||
count, err = res.VerifyFiles(ctx, opts.Target, countRestoredFiles, bar)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -62,11 +62,6 @@ func newTerminalProgressMax(show bool, max uint64, description string, term *ter
|
||||
})
|
||||
}
|
||||
|
||||
// newProgressMax calls newTerminalProgress without a terminal (print to stdout)
|
||||
func newProgressMax(show bool, max uint64, description string) *progress.Counter {
|
||||
return newGenericProgressMax(show, max, description, printProgress)
|
||||
}
|
||||
|
||||
func printProgress(status string, final bool) {
|
||||
canUpdateStatus := terminal.StdoutCanUpdateStatus()
|
||||
|
||||
@@ -103,7 +98,7 @@ func printProgress(status string, final bool) {
|
||||
}
|
||||
|
||||
func newIndexProgress(quiet bool, json bool) *progress.Counter {
|
||||
return newProgressMax(!quiet && !json && terminal.StdoutIsTerminal(), 0, "index files loaded")
|
||||
return newGenericProgressMax(!quiet && !json && terminal.StdoutIsTerminal(), 0, "index files loaded", printProgress)
|
||||
}
|
||||
|
||||
type terminalProgressPrinter struct {
|
||||
|
||||
Reference in New Issue
Block a user