From 6a91d0a864f9edd9d9fe50ca89ccbce4fc98e043 Mon Sep 17 00:00:00 2001 From: fxqnlr Date: Wed, 4 Sep 2024 11:12:04 +0200 Subject: do nearly anything to shut clippy up --- src/commands/download.rs | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) (limited to 'src/commands/download.rs') diff --git a/src/commands/download.rs b/src/commands/download.rs index 3e50c87..7321832 100644 --- a/src/commands/download.rs +++ b/src/commands/download.rs @@ -1,9 +1,11 @@ +#![allow(clippy::too_many_lines)] + use indicatif::{MultiProgress, ProgressBar, ProgressStyle}; use crate::{config::Cfg, List}; use crate::{ db::userlist_get_all_current_versions_with_mods, - error::{ErrorType, MLError, MLE}, + error::{EType, MLErr, MLE}, files::{ clean_list_dir, delete_version, disable_version, download_versions, get_downloaded_versions, @@ -12,6 +14,8 @@ use crate::{ }; use crate::{PROGRESS_CHARS, STYLE_BAR_POS}; +/// # Errors +/// # Panics pub async fn download( config: &Cfg, liststack: Vec, @@ -31,15 +35,15 @@ pub async fn download( download_p.set_message(format!("Download in {}", current_list.id)); let downloaded_versions = - get_downloaded_versions(current_list.clone())?; + get_downloaded_versions(¤t_list)?; let current_version_ids = match userlist_get_all_current_versions_with_mods( config, - String::from(¤t_list.id), + ¤t_list.id, ) { Ok(i) => Ok(i), - Err(e) => Err(MLError::new( - ErrorType::DBError, + Err(e) => Err(MLErr::new( + EType::DBError, e.to_string().as_str(), )), }?; @@ -74,7 +78,12 @@ pub async fn download( clean_list_dir(¤t_list)?; }; - if !to_download.is_empty() { + if to_download.is_empty() { + download_p.println(format!( + "There are no new versions to download for {}", + current_list.id + )); + } else { download_versions( current_list.clone(), config.clone(), @@ -83,11 +92,6 @@ pub async fn download( &download_p, ) .await?; - } else { - download_p.println(format!( - "There are no new versions to download for {}", - current_list.id - )); } if !to_disable.is_empty() { @@ -104,13 +108,13 @@ pub async fn download( if delete_old { d_p.set_message(format!("Delete version {}", ver.1)); d_p.inc(1); - delete_version(¤t_list, ver.1)?; + delete_version(¤t_list, &ver.1)?; } else { d_p.set_message(format!("Disable version {}", ver.1)); d_p.inc(1); disable_version( config, - current_list.clone(), + ¤t_list, ver.1, ver.0, )?; -- cgit v1.2.3