diff options
author | Matthias Beyer <matthias.beyer@atos.net> | 2021-12-02 14:10:36 +0100 |
---|---|---|
committer | Matthias Beyer <matthias.beyer@atos.net> | 2021-12-02 14:23:52 +0100 |
commit | 51aded70fdb992ea873db88b2348e47ac2177bdb (patch) | |
tree | 8f3cfa98512c6b2e39fcc0d65e54cf8e4118490f | |
parent | 17351984e3935f3273a03ecff24776a5acd381e4 (diff) |
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 <matthias.beyer@atos.net>
-rw-r--r-- | src/commands/source/download.rs | 7 |
1 files changed, 1 insertions, 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(()) |