From 51aded70fdb992ea873db88b2348e47ac2177bdb Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 2 Dec 2021 14:10:36 +0100 Subject: Optimize: Do not increase the download counter too soon Because if the check fails, we don't have to do this work actually. Signed-off-by: Matthias Beyer --- src/commands/source/download.rs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/commands/source/download.rs b/src/commands/source/download.rs index b73a074..ce467e4 100644 --- a/src/commands/source/download.rs +++ b/src/commands/source/download.rs @@ -218,18 +218,13 @@ pub async fn download( if source_path_exists && !force { Err(anyhow!("Source exists: {}", source.path().display())) } else { - progressbar.lock() - .await - .inc_download_count() - .await; - if source_path_exists /* && force is implied by 'if' above*/ { if let Err(e) = source.remove_file().await { - progressbar.lock().await.finish_one_download().await; return Err(e) } } + progressbar.lock().await.inc_download_count().await; perform_download(&source, progressbar.clone(), timeout).await?; progressbar.lock().await.finish_one_download().await; Ok(()) -- cgit v1.2.3