From c6061b519822511a92975d56562dd3c7181ed421 Mon Sep 17 00:00:00 2001 From: fxqnlr Date: Sat, 7 Jan 2023 13:25:00 +0100 Subject: moved update in own function --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/commands/update.rs | 24 ++++++++++++++---------- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 788f68c..ac1cd5e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -615,7 +615,7 @@ dependencies = [ [[package]] name = "modlist" -version = "0.8.0" +version = "0.8.1" dependencies = [ "chrono", "dirs", diff --git a/Cargo.toml b/Cargo.toml index 6e9c282..76b31d4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "modlist" -version = "0.8.0" +version = "0.8.1" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/src/commands/update.rs b/src/commands/update.rs index 0895efb..11f283e 100644 --- a/src/commands/update.rs +++ b/src/commands/update.rs @@ -3,7 +3,7 @@ use std::io::{Error, ErrorKind}; use crate::{config::Cfg, modrinth::{projects, Project, versions, extract_current_version, Version}, get_current_list, db::{userlist_get_all_ids, mods_get_versions, userlist_get_applicable_versions, userlist_change_versions, lists_get_all_ids, lists_get, userlist_get_current_version, mods_change_versions}, List, input::Input, files::{delete_version, download_versions, disable_version}}; pub async fn update(config: Cfg, input: Input) -> Result<(), Box> { - + let mut liststack: Vec = vec![]; if input.all_lists { let list_ids = lists_get_all_ids(config.clone())?; @@ -15,7 +15,11 @@ pub async fn update(config: Cfg, input: Input) -> Result<(), Box, clean: bool, direct_download: bool, delete_old: bool) -> Result<(), Box> { for current_list in liststack { let mods = userlist_get_all_ids(config.clone(), current_list.clone().id)?; @@ -41,17 +45,17 @@ pub async fn update(config: Cfg, input: Input) -> Result<(), Box { current_versions.push((disable_version, p_id)); ver }, //TODO handle errors (only continue on "NO_UPDATE_AVAILABLE") - Err(e) => { + Err(..) => { //Updating versions in modlist for no repeating version calls mods_change_versions(config.clone(), version_db_string, project.id)?; - println!("({}) No new version found for the specified minecraft version({})", project.title, e); + println!("({}) No new version found for the specified", project.title); continue; }, }); @@ -60,7 +64,7 @@ pub async fn update(config: Cfg, input: Input) -> Result<(), Box Result<(), Box Result<(), Box Result> { +async fn specific_update(config: Cfg, clean: bool, list: List, project: Project) -> Result> { println!("Checking update for '{}' in {}", project.title, list.id); let applicable_versions = versions(String::from(&config.apis.modrinth), String::from(&project.id), list.clone()).await; @@ -106,7 +110,7 @@ async fn specific_update(config: Cfg, input: Input, list: List, project: Project let mut current: Vec = vec![]; - if input.clean || (versions.join("|") != userlist_get_applicable_versions(config.clone(), String::from(&list.id), String::from(&project.id))?) { + if clean || (versions.join("|") != userlist_get_applicable_versions(config.clone(), String::from(&list.id), String::from(&project.id))?) { //get new versions print!(" | getting new version"); let current_str = extract_current_version(applicable_versions.clone())?; -- cgit v1.2.3