From 942558c75200aaad0b4d8561a1f6999f88f843a4 Mon Sep 17 00:00:00 2001 From: fxqnlr Date: Wed, 4 Sep 2024 12:31:02 +0200 Subject: remove allow too_many_lines and fix them --- src/commands/update.rs | 84 ++++++++++++++++++++++++++------------------------ 1 file changed, 44 insertions(+), 40 deletions(-) (limited to 'src/commands/update.rs') diff --git a/src/commands/update.rs b/src/commands/update.rs index c7965e3..f83030d 100644 --- a/src/commands/update.rs +++ b/src/commands/update.rs @@ -1,5 +1,3 @@ -#![allow(clippy::too_many_lines)] - use indicatif::{MultiProgress, ProgressBar, ProgressStyle}; use crate::{ @@ -70,44 +68,7 @@ pub async fn update( let mut updatestack: Vec = vec![]; for id in mods { - let info = mods_get_info(config, &id)?; - list_u_p.set_message(format!("Update {}", info.title)); - - //Skip check if version is set - if userlist_get_set_version(config, ¤t_list.id, &id)? { - list_u_p.inc(1); - continue; - } - - //Getting current installed version for disable or delete - let disable_version = - userlist_get_current_version(config, ¤t_list.id, &id)?; - - updatestack.push( - match specific_update( - config, - clean, - current_list.clone(), - &id, - &list_u_p, - ) - .await - { - Ok(ver) => { - current_versions.push((disable_version, id)); - ver - } - Err(e) => { - if e.to_string() == "Mod: NO_UPDATE_AVAILABLE" { - } else { - return Err(e); - }; - list_u_p.inc(1); - continue; - } - }, - ); - list_u_p.inc(1); + update_mod(config, id, list_u_p.clone(), ¤t_list, &mut updatestack, &mut current_versions, clean).await?; } list_u_p.finish_with_message(format!( @@ -173,6 +134,49 @@ pub async fn update( Ok(()) } +async fn update_mod(config: &Cfg, id: String, list_u_p: ProgressBar, current_list: &List, updatestack: &mut Vec, current_versions: &mut Vec<(String, String)>, clean: bool) -> MLE<()> { + let info = mods_get_info(config, &id)?; + list_u_p.set_message(format!("Update {}", info.title)); + + //Skip check if version is set + if userlist_get_set_version(config, ¤t_list.id, &id)? { + list_u_p.inc(1); + return Ok(()); + } + + //Getting current installed version for disable or delete + let disable_version = + userlist_get_current_version(config, ¤t_list.id, &id)?; + + updatestack.push( + match specific_update( + config, + clean, + current_list.clone(), + &id, + &list_u_p, + ) + .await + { + Ok(ver) => { + current_versions.push((disable_version, id.to_string())); + ver + } + Err(e) => { + if e.to_string() == "Mod: NO_UPDATE_AVAILABLE" { + } else { + return Err(e); + }; + list_u_p.inc(1); + return Ok(()); + } + }, + ); + list_u_p.inc(1); + + Ok(()) +} + async fn specific_update( config: &Cfg, clean: bool, -- cgit v1.2.3