From f083d7e70187d631dee54922119caef9f8b3e27e Mon Sep 17 00:00:00 2001 From: Chewing_Bever Date: Sun, 4 Jun 2023 08:57:31 +0200 Subject: [PATCH] feat: ability to disable backup thread --- src/main.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index 35a5b9d..72f8cb8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -39,8 +39,8 @@ struct Cli { /// How many backups to keep #[arg(short = 'n', long, default_value_t = 7)] max_backups: u64, - /// How frequently to perform a backup, in minutes - #[arg(short = 't', long, default_value_t = 720)] + /// How frequently to perform a backup, in minutes; 0 to disable. + #[arg(short = 't', long, default_value_t = 0)] frequency: u64, } @@ -69,8 +69,10 @@ fn main() { .max_backups(cli.max_backups); let counter = Arc::new(Mutex::new(cmd.spawn().expect("Failed to start server."))); - let clone = Arc::clone(&counter); - std::thread::spawn(move || backups_thread(clone, cli.frequency)); + if cli.frequency > 0 { + let clone = Arc::clone(&counter); + std::thread::spawn(move || backups_thread(clone, cli.frequency)); + } let stdin = io::stdin(); let input = &mut String::new();