From a6e408a5e14560ea3b727b0895795c1978ce2a8e Mon Sep 17 00:00:00 2001 From: Daniel M Date: Thu, 1 Apr 2021 23:04:52 +0200 Subject: [PATCH] Add delay between connection attempts --- src/download.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/download.rs b/src/download.rs index 9f0182f..4197a78 100644 --- a/src/download.rs +++ b/src/download.rs @@ -270,6 +270,9 @@ pub async fn download_feedback_multi(url: &str, into_file: &str, rep: DlReporter let specific_content_length = from_to.1 - from_to.0 + 1; + // Delay each chunk-download to reduce the number of simultanious connection attempts + tokio::time::sleep(tokio::time::Duration::from_millis(50 *index as u64)).await; + download_feedback_chunks(&url, &into_file, rep, Some(from_to), true, Some(specific_content_length)).await.map_err(|e| e.to_string()) }))