Support values less than 1 for RESTIC_PROGRESS_FPS

For example set the variable to 0.016666 to print the progress once per
minute.
This commit is contained in:
Michael Eischer 2020-12-29 15:24:02 +01:00
parent 92da5168e1
commit 05a987b07c
2 changed files with 5 additions and 4 deletions

View File

@ -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
}

View File

@ -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