From d7a540f560e4d0a9901770e3f56446c34679475c Mon Sep 17 00:00:00 2001 From: yggverse Date: Sun, 10 Aug 2025 07:23:38 +0300 Subject: [PATCH] implement `wait_until_completed` timeout --- src/config.rs | 5 +++++ src/main.rs | 12 +++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/config.rs b/src/config.rs index 0b113f2..8f1cab6 100644 --- a/src/config.rs +++ b/src/config.rs @@ -120,4 +120,9 @@ pub struct Config { /// Limit download speed (b/s) #[arg(long)] pub download_limit: Option, + + /// Skip long-thinking connections, + /// try to handle the other hashes in this queue after `n` seconds + #[arg(long, default_value_t = 10)] + pub wait_until_completed: u64, } diff --git a/src/main.rs b/src/main.rs index 7ef06b7..d0ed5c2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -184,7 +184,17 @@ async fn main() -> Result<()> { session.unpause(&mt).await?; log::debug!("begin torrent `{i}` preload..."); // await for `preload_regex` files download to continue - mt.wait_until_completed().await?; + if let Err(e) = time::timeout( + Duration::from_secs(config.wait_until_completed), + mt.wait_until_completed(), + ) + .await + { + log::debug!( + "skip awaiting the completion of preload `{i}` data (`{e}`)" + ); + continue; + } log::debug!("torrent `{i}` preload completed."); // persist torrent bytes and preloaded content, // cleanup tmp (see rqbit#408)