Add tracker refresh interval parameter

This commit is contained in:
Igor Katson 2021-06-29 00:17:10 +01:00
parent c2affa8865
commit 2fc225cfa2
3 changed files with 66 additions and 49 deletions

View file

@ -1,4 +1,4 @@
use std::{fs::File, io::Read};
use std::{fs::File, io::Read, time::Duration};
use anyhow::Context;
use clap::Clap;
@ -60,6 +60,8 @@ struct Opts {
/// The filename of the .torrent file.
output_folder: String,
/// If set, only the file whose filename matching this regex will
/// be downloaded
#[clap(short = 'r', long = "filename-re")]
only_files_matching_regex: Option<String>,
@ -71,8 +73,15 @@ struct Opts {
#[clap(short, long)]
list: bool,
/// The loglevel
#[clap(arg_enum, short = 'v')]
log_level: Option<LogLevel>,
/// The interval in seconds to poll trackers.
/// Trackers send the refresh interval when we connect to them. Often this is
/// pretty big, e.g. 30 minutes. This can force a certain value.
#[clap(short = 'i', long = "tracker-refresh-interval")]
force_tracker_interval: Option<u64>,
}
fn compute_only_files(
@ -162,6 +171,10 @@ fn main() -> anyhow::Result<()> {
builder.only_files(only_files);
}
if let Some(interval) = opts.force_tracker_interval {
builder.force_tracker_interval(Duration::from_secs(interval));
}
let manager_handle = builder.start_manager().await?;
manager_handle.wait_until_completed().await?;
Ok(())