~matthiasbeyer/butido

51aded70fdb992ea873db88b2348e47ac2177bdb — Matthias Beyer 1 year, 9 months ago 1735198
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>
1 files changed, 1 insertions(+), 6 deletions(-)

M src/commands/source/download.rs
M src/commands/source/download.rs => src/commands/source/download.rs +1 -6
@@ 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(())