diff --git a/cmd/restic/cmd_backup.go b/cmd/restic/cmd_backup.go index d4ec3c288..037b61103 100644 --- a/cmd/restic/cmd_backup.go +++ b/cmd/restic/cmd_backup.go @@ -547,7 +547,7 @@ func runBackup(opts BackupOptions, gopts GlobalOptions, term *termstatus.Termina }() gopts.stdout, gopts.stderr = progressPrinter.Stdout(), progressPrinter.Stderr() - progressReporter.SetMinUpdatePause(calculateProgressInterval(!gopts.Quiet)) + progressReporter.SetMinUpdatePause(calculateProgressInterval(!gopts.Quiet, gopts.JSON)) t.Go(func() error { return progressReporter.Run(t.Context(gopts.ctx)) }) diff --git a/cmd/restic/progress.go b/cmd/restic/progress.go index 26a694c25..5a77bc6ee 100644 --- a/cmd/restic/progress.go +++ b/cmd/restic/progress.go @@ -14,7 +14,7 @@ import ( // calculateProgressInterval returns the interval configured via RESTIC_PROGRESS_FPS // or if unset returns an interval for 60fps on interactive terminals and 0 (=disabled) // for non-interactive terminals or when run using the --quiet flag -func calculateProgressInterval(show bool) time.Duration { +func calculateProgressInterval(show bool, json bool) time.Duration { interval := time.Second / 60 fps, err := strconv.ParseFloat(os.Getenv("RESTIC_PROGRESS_FPS"), 64) if err == nil && fps > 0 { @@ -22,7 +22,7 @@ func calculateProgressInterval(show bool) time.Duration { fps = 60 } interval = time.Duration(float64(time.Second) / fps) - } else if !stdoutCanUpdateStatus() || !show { + } else if !json && !stdoutCanUpdateStatus() || !show { interval = 0 } return interval @@ -33,7 +33,7 @@ func newProgressMax(show bool, max uint64, description string) *progress.Counter if !show { return nil } - interval := calculateProgressInterval(show) + interval := calculateProgressInterval(show, false) canUpdateStatus := stdoutCanUpdateStatus() return progress.New(interval, max, func(v uint64, max uint64, d time.Duration, final bool) {