feat: ability to disable backup thread
parent
3c5cdaef4f
commit
f083d7e701
|
@ -39,8 +39,8 @@ struct Cli {
|
||||||
/// How many backups to keep
|
/// How many backups to keep
|
||||||
#[arg(short = 'n', long, default_value_t = 7)]
|
#[arg(short = 'n', long, default_value_t = 7)]
|
||||||
max_backups: u64,
|
max_backups: u64,
|
||||||
/// How frequently to perform a backup, in minutes
|
/// How frequently to perform a backup, in minutes; 0 to disable.
|
||||||
#[arg(short = 't', long, default_value_t = 720)]
|
#[arg(short = 't', long, default_value_t = 0)]
|
||||||
frequency: u64,
|
frequency: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,8 +69,10 @@ fn main() {
|
||||||
.max_backups(cli.max_backups);
|
.max_backups(cli.max_backups);
|
||||||
let counter = Arc::new(Mutex::new(cmd.spawn().expect("Failed to start server.")));
|
let counter = Arc::new(Mutex::new(cmd.spawn().expect("Failed to start server.")));
|
||||||
|
|
||||||
|
if cli.frequency > 0 {
|
||||||
let clone = Arc::clone(&counter);
|
let clone = Arc::clone(&counter);
|
||||||
std::thread::spawn(move || backups_thread(clone, cli.frequency));
|
std::thread::spawn(move || backups_thread(clone, cli.frequency));
|
||||||
|
}
|
||||||
|
|
||||||
let stdin = io::stdin();
|
let stdin = io::stdin();
|
||||||
let input = &mut String::new();
|
let input = &mut String::new();
|
||||||
|
|
Loading…
Reference in New Issue