From 87947ce38476e7a5fb8d4db1bc9e0b584aa965ca Mon Sep 17 00:00:00 2001 From: fxqnlr Date: Wed, 3 May 2023 08:29:31 +0200 Subject: added async trait? WHY --- src/lib.rs | 5 +++-- src/main.rs | 7 +++---- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/lib.rs b/src/lib.rs index b48bf61..f18bdfb 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -76,7 +76,7 @@ pub fn load_game_versions(path: &str) -> MLE> { let versions: Vec = serde_json::from_str(&data)?; Ok(versions) } - + impl VersionLevel { pub fn from(str: &str) -> Self { @@ -87,8 +87,9 @@ impl VersionLevel { } } - pub fn get(self, versions_path: &str) -> MLE { + pub async fn get(self, versions_path: &str, force_update: bool) -> MLE { let path = format!("{}/versions.json", versions_path); + check_game_versions(&path, force_update).await?; let mut versions = load_game_versions(&path)?.into_iter(); match self { diff --git a/src/main.rs b/src/main.rs index 93da718..b12e3e4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,7 +3,7 @@ use modlist::{ config::Cfg, db::{config_get_current_list, lists_get, lists_get_all_ids}, download, export, get_current_list, import, list_add, list_change, list_remove, list_version, - mod_add, mod_remove, update, IDSelector, List, Modloader, check_game_versions, VersionLevel, + mod_add, mod_remove, update, IDSelector, List, Modloader, VersionLevel, }; //TODO implement remote sql db @@ -153,7 +153,6 @@ async fn main() { let cli = Cli::parse(); let config = Cfg::init(cli.config).await.unwrap(); - check_game_versions(format!("{}/versions.json", config.versions).as_str(), cli.force_gameupdate).await.unwrap(); match cli.command { Commands::Mod { command } => { @@ -212,8 +211,8 @@ async fn main() { let versions_path = &config.versions; let ver = match version { - Some(ver) => VersionLevel::from(&ver).get(versions_path).unwrap(), - None => config.clone().defaults.version.get(versions_path).unwrap(), + Some(ver) => VersionLevel::from(&ver).get(versions_path, cli.force_gameupdate).await.unwrap(), + None => config.clone().defaults.version.get(versions_path, cli.force_gameupdate).await.unwrap(), }; list_add(config, id, ver, ml, directory) -- cgit v1.2.3