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 committed 2020-12-29 16:32:18 +01:00
1 parent 92da5168e1
commit 05a987b07c
2 files changed
+5 -4

No files matched your search

+3 -3
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
}