diff --git a/src/config.rs b/src/config.rs index 3ba56f4..caa0fb4 100644 --- a/src/config.rs +++ b/src/config.rs @@ -98,7 +98,7 @@ pub struct Config { #[arg(long, default_value_t = 60)] pub add_torrent_timeout: u64, - /// Ban time in seconds on torrent add failure + /// Ban time in seconds on torrent add failure (`add_torrent_timeout` is reached) #[arg(long, default_value_t = 3600)] pub add_torrent_ban: u64, @@ -106,6 +106,10 @@ pub struct Config { #[arg(long, default_value_t = 3600)] pub resolve_torrent_ban: u64, + /// Ban time in seconds on torrent data download is longer than `add_torrent_timeout` + #[arg(long)] + pub slow_torrent_ban: Option, + /// Crawl loop delay in seconds #[arg(long, default_value_t = 60)] pub sleep: u64, diff --git a/src/main.rs b/src/main.rs index 9633596..1159d0c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -198,12 +198,20 @@ async fn main() -> Result<()> { ) .await { - log::debug!( - "skip awaiting the completion of preload `{h}` data (`{e}`)" - ); session .delete(librqbit::api::TorrentIdOrHash::Id(id), false) .await?; // * do not collect billions of slow torrents in the session pool + if let Some(slow_torrent_ban) = config.slow_torrent_ban { + let t = Local::now() + Duration::from_secs(slow_torrent_ban); + log::debug!( + "skip awaiting the completion of preload `{h}` data (`{e}`), ban until {t}." + ); + assert!(ban.insert(i, t).is_none()); + } else { + log::debug!( + "skip awaiting the completion of preload `{h}` data (`{e}`)" + ); + } continue; } log::debug!("torrent `{h}` preload completed.");