From 05a987b07c48d0ed785354d135d63a9e69dfa457 Mon Sep 17 00:00:00 2001 From: Michael Eischer Date: Tue, 29 Dec 2020 15:24:02 +0100 Subject: [PATCH] Support values less than 1 for RESTIC_PROGRESS_FPS For example set the variable to 0.016666 to print the progress once per minute. --- cmd/restic/progress.go | 6 +++--- doc/manual_rest.rst | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/cmd/restic/progress.go b/cmd/restic/progress.go index bb0bcd9fa..2fbd97c6c 100644 --- a/cmd/restic/progress.go +++ b/cmd/restic/progress.go @@ -14,12 +14,12 @@ import ( // for non-interactive terminals func calculateProgressInterval() time.Duration { interval := time.Second / 60 - fps, err := strconv.ParseInt(os.Getenv("RESTIC_PROGRESS_FPS"), 10, 64) - if err == nil && fps >= 1 { + fps, err := strconv.ParseFloat(os.Getenv("RESTIC_PROGRESS_FPS"), 64) + if err == nil && fps > 0 { if fps > 60 { fps = 60 } - interval = time.Second / time.Duration(fps) + interval = time.Duration(float64(time.Second) / fps) } else if !stdoutIsTerminal() { interval = 0 } diff --git a/doc/manual_rest.rst b/doc/manual_rest.rst index 3e567b359..d8167fb4a 100644 --- a/doc/manual_rest.rst +++ b/doc/manual_rest.rst @@ -138,7 +138,8 @@ Subcommands that support showing progress information such as ``backup``, ``--quiet`` is set. When running from a non-interactive console progress reporting is disabled by default to not fill your logs. For interactive and non-interactive consoles the environment variable ``RESTIC_PROGRESS_FPS`` -can be used to control the frequency of progress reporting. +can be used to control the frequency of progress reporting. Use for example +``0.016666`` to only update the progress once per minute. Additionally, on Unix systems if ``restic`` receives a SIGUSR1 signal the current progress will be written to the standard output so you can check up