From 969141b5e964c77e9d83ed09e36c4481932024dd Mon Sep 17 00:00:00 2001 From: Michael Eischer Date: Mon, 28 Dec 2020 23:15:14 +0100 Subject: [PATCH] Honor RESTIC_PROGRESS_FPS env variable on non-interactive terminals This makes it possible to use the environment variable to also get regular progress updates on non-interactive terminals. --- cmd/restic/progress.go | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/cmd/restic/progress.go b/cmd/restic/progress.go index 4407f3760..b311af3b9 100644 --- a/cmd/restic/progress.go +++ b/cmd/restic/progress.go @@ -16,16 +16,14 @@ func newProgressMax(show bool, max uint64, description string) *progress.Counter } interval := time.Second / 60 - if !stdoutIsTerminal() { - interval = 0 - } else { - fps, err := strconv.ParseInt(os.Getenv("RESTIC_PROGRESS_FPS"), 10, 64) - if err == nil && fps >= 1 { - if fps > 60 { - fps = 60 - } - interval = time.Second / time.Duration(fps) + fps, err := strconv.ParseInt(os.Getenv("RESTIC_PROGRESS_FPS"), 10, 64) + if err == nil && fps >= 1 { + if fps > 60 { + fps = 60 } + interval = time.Second / time.Duration(fps) + } else if !stdoutIsTerminal() { + interval = 0 } return progress.New(interval, func(v uint64, d time.Duration, final bool) {