From a789b507165df65b89a9b9b6c4e28dff36e97c61 Mon Sep 17 00:00:00 2001 From: aawsome <37850842+aawsome@users.noreply.github.com> Date: Tue, 10 Dec 2024 14:34:35 +0100 Subject: [PATCH] fix(config): set a non-zero default progress interval for progress options (#1378) --- src/config/progress_options.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/config/progress_options.rs b/src/config/progress_options.rs index fcb201e99..8adf3f7d9 100644 --- a/src/config/progress_options.rs +++ b/src/config/progress_options.rs @@ -12,6 +12,12 @@ use serde_with::{serde_as, DisplayFromStr}; use rustic_core::{Progress, ProgressBars}; +mod constants { + use std::time::Duration; + + pub(super) const DEFAULT_INTERVAL: Duration = Duration::from_millis(100); +} + /// Progress Bar Config #[serde_as] #[derive(Default, Debug, Parser, Clone, Copy, Deserialize, Serialize, Merge)] @@ -22,7 +28,7 @@ pub struct ProgressOptions { #[merge(strategy=conflate::bool::overwrite_false)] pub no_progress: bool, - /// Interval to update progress bars + /// Interval to update progress bars (default: 100ms) #[clap( long, global = true, @@ -37,12 +43,9 @@ pub struct ProgressOptions { impl ProgressOptions { /// Get the progress interval - /// - /// # Returns - /// - /// `Duration::ZERO` if no progress is enabled fn progress_interval(&self) -> Duration { - self.progress_interval.map_or(Duration::ZERO, |i| *i) + self.progress_interval + .map_or(constants::DEFAULT_INTERVAL, |i| *i) } /// Create a hidden progress bar