From c7ecf3019a75dc0ab1a0aefeb9b880899fc8a231 Mon Sep 17 00:00:00 2001 From: fxqnlr Date: Mon, 29 May 2023 18:01:12 +0200 Subject: cargo fmt and add fmt file --- src/commands/update.rs | 56 +++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 44 insertions(+), 12 deletions(-) (limited to 'src/commands/update.rs') diff --git a/src/commands/update.rs b/src/commands/update.rs index 3aae002..c19c02c 100644 --- a/src/commands/update.rs +++ b/src/commands/update.rs @@ -4,10 +4,13 @@ use crate::{ config::Cfg, db::{ mods_get_info, userlist_change_versions, userlist_get_all_ids, - userlist_get_applicable_versions, userlist_get_current_version, userlist_get_set_version, + userlist_get_applicable_versions, userlist_get_current_version, + userlist_get_set_version, }, error::{ErrorType, MLError, MLE}, - files::{clean_list_dir, delete_version, disable_version, download_versions}, + files::{ + clean_list_dir, delete_version, disable_version, download_versions, + }, modrinth::{extract_current_version, versions, Version}, List, PROGRESS_CHARS, STYLE_BAR_POS, STYLE_OPERATION, }; @@ -21,7 +24,8 @@ pub async fn update( ) -> MLE<()> { let mp = MultiProgress::new(); - let update_p = mp.add(ProgressBar::new(liststack.len().try_into().unwrap())); + let update_p = + mp.add(ProgressBar::new(liststack.len().try_into().unwrap())); update_p.set_style( ProgressStyle::with_template(STYLE_BAR_POS) .unwrap() @@ -32,12 +36,16 @@ pub async fn update( update_p.set_message(format!("Update {}", current_list.id)); let list_p = mp.insert_before(&update_p, ProgressBar::new(2)); - list_p.set_style(ProgressStyle::with_template(STYLE_OPERATION).unwrap()); + list_p + .set_style(ProgressStyle::with_template(STYLE_OPERATION).unwrap()); list_p.set_message("Update mods"); let mods = userlist_get_all_ids(config, ¤t_list.id)?; - let list_u_p = mp.insert_before(&list_p, ProgressBar::new(mods.len().try_into().unwrap())); + let list_u_p = mp.insert_before( + &list_p, + ProgressBar::new(mods.len().try_into().unwrap()), + ); list_u_p.set_style( ProgressStyle::with_template(STYLE_BAR_POS) .unwrap() @@ -58,10 +66,19 @@ pub async fn update( } //Getting current installed version for disable or delete - let disable_version = userlist_get_current_version(config, ¤t_list.id, &id)?; + 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 { + match specific_update( + config, + clean, + current_list.clone(), + &id, + &list_u_p, + ) + .await + { Ok(ver) => { current_versions.push((disable_version, id)); ver @@ -79,7 +96,10 @@ pub async fn update( list_u_p.inc(1); } - list_u_p.finish_with_message(format!("Updated mods in {}", current_list.id)); + list_u_p.finish_with_message(format!( + "Updated mods in {}", + current_list.id + )); if clean { list_p.set_message("Cleaning"); @@ -100,7 +120,9 @@ pub async fn update( if !clean { let d_p = mp.insert_before( &list_p, - ProgressBar::new(current_versions.len().try_into().unwrap()), + ProgressBar::new( + current_versions.len().try_into().unwrap(), + ), ); d_p.set_style( ProgressStyle::with_template(STYLE_BAR_POS) @@ -115,7 +137,12 @@ pub async fn update( } else if ver.0 != "NONE" { d_p.set_message(format!("Disable version {}", ver.0)); d_p.inc(1); - disable_version(config, current_list.clone(), ver.0, ver.1)?; + disable_version( + config, + current_list.clone(), + ver.0, + ver.1, + )?; }; } @@ -144,7 +171,8 @@ async fn specific_update( id: &str, progress: &ProgressBar, ) -> MLE { - let applicable_versions = versions(&config.apis.modrinth, String::from(id), list.clone()).await; + let applicable_versions = + versions(&config.apis.modrinth, String::from(id), list.clone()).await; let mut versions: Vec = vec![]; @@ -159,7 +187,11 @@ async fn specific_update( let mut current: Vec = vec![]; if clean || (versions.join("|") - != userlist_get_applicable_versions(config, String::from(&list.id), String::from(id))?) + != userlist_get_applicable_versions( + config, + String::from(&list.id), + String::from(id), + )?) { let current_str = extract_current_version(applicable_versions.clone())?; -- cgit v1.2.3