From 48393b209396db9ddd44251b2bb445d3ad7533fb Mon Sep 17 00:00:00 2001 From: fxqnlr Date: Thu, 25 May 2023 17:23:52 +0200 Subject: changed a whole lot og references, fuck rust --- src/commands/update.rs | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) (limited to 'src/commands/update.rs') diff --git a/src/commands/update.rs b/src/commands/update.rs index 2de13f3..7482e43 100644 --- a/src/commands/update.rs +++ b/src/commands/update.rs @@ -9,13 +9,11 @@ use crate::{ error::{ErrorType, MLError, MLE}, files::{clean_list_dir, delete_version, disable_version, download_versions}, modrinth::{extract_current_version, versions, Version}, - List, + List, PROGRESS_CHARS, }; -const PROGRESS_CHARS: &str = "#>-"; - pub async fn update( - config: Cfg, + config: &Cfg, liststack: Vec, clean: bool, direct_download: bool, @@ -33,7 +31,7 @@ pub async fn update( for current_list in liststack { // println!("Update mods in {}", current_list.id); - let mods = userlist_get_all_ids(config.clone(), ¤t_list.id)?; + let mods = userlist_get_all_ids(config, ¤t_list.id)?; let list_p = mp.insert_before(&update_p, ProgressBar::new(mods.len().try_into().unwrap())); list_p.set_style(bar_style.clone()); @@ -47,11 +45,11 @@ pub async fn update( let mod_p = mp.insert_before(&list_p, ProgressBar::new(1)); mod_p.set_style(spinner_style.clone()); - let info = mods_get_info(&config, &id)?; + let info = mods_get_info(config, &id)?; mod_p.set_message(format!("Update {}", info.title)); // println!(" ├{}", info.title); - if userlist_get_set_version(config.clone(), ¤t_list.id, &id)? { + if userlist_get_set_version(config, ¤t_list.id, &id)? { // println!(" │ └Set version, skipping update"); list_p.inc(1); continue; @@ -59,16 +57,16 @@ pub async fn update( //Getting current installed version for disable or delete let disable_version = - userlist_get_current_version(config.clone(), ¤t_list.id, &id)?; + userlist_get_current_version(config, ¤t_list.id, &id)?; mod_p.inc(1); updatestack.push( match specific_update( - config.clone(), + config, clean, current_list.clone(), - String::from(&id), + &id, &mod_p ) .await @@ -112,7 +110,7 @@ pub async fn update( delete_version(current_list.clone(), ver.0)?; } else if ver.0 != "NONE" { println!(" └Disable version {}", ver.0); - disable_version(config.clone(), current_list.clone(), ver.0, ver.1)?; + disable_version(config, current_list.clone(), ver.0, ver.1)?; }; } } @@ -126,9 +124,9 @@ pub async fn update( Ok(()) } -async fn specific_update(config: Cfg, clean: bool, list: List, id: String, progress: &ProgressBar) -> MLE { +async fn specific_update(config: &Cfg, clean: bool, list: List, id: &str, progress: &ProgressBar) -> MLE { let applicable_versions = - versions(&config.apis.modrinth, String::from(&id), list.clone()).await; + versions(&config.apis.modrinth, String::from(id), list.clone()).await; let mut versions: Vec = vec![]; @@ -144,9 +142,9 @@ async fn specific_update(config: Cfg, clean: bool, list: List, id: String, progr if clean || (versions.join("|") != userlist_get_applicable_versions( - config.clone(), + config, String::from(&list.id), - String::from(&id), + String::from(id), )?) { let current_str = extract_current_version(applicable_versions.clone())?; @@ -154,7 +152,7 @@ async fn specific_update(config: Cfg, clean: bool, list: List, id: String, progr if clean { // println!("\t └Add version to downloadstack"); } else { - progress.println(format!("Found new version for {}", mods_get_info(&config, &id).unwrap().title)); + progress.println(format!("Found new version for {}", mods_get_info(config, id).unwrap().title)); // println!("\t └Get versions for specified minecraft versions"); // println!("\t └New current version: {}", current_str); }; @@ -178,7 +176,7 @@ async fn specific_update(config: Cfg, clean: bool, list: List, id: String, progr } .url; - userlist_change_versions(config, list.id, current_str, versions.join("|"), link, id)?; + userlist_change_versions(config, list.id, current_str, versions.join("|"), link, id.to_string())?; } if current.is_empty() { -- cgit v1.2.3