From 6a91d0a864f9edd9d9fe50ca89ccbce4fc98e043 Mon Sep 17 00:00:00 2001 From: fxqnlr Date: Wed, 4 Sep 2024 11:12:04 +0200 Subject: do nearly anything to shut clippy up --- src/config.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/config.rs') diff --git a/src/config.rs b/src/config.rs index 3538a69..6280932 100644 --- a/src/config.rs +++ b/src/config.rs @@ -8,7 +8,7 @@ use indicatif::{ProgressBar, ProgressStyle}; use serde::{Deserialize, Serialize}; use crate::{ - check_game_versions, db::db_setup, error::MLE, Modloader, VersionLevel, + check_game_versions, db::setup, error::{EType, MLErr, MLE}, Modloader, VersionLevel, }; #[derive(Debug, Clone, Serialize, Deserialize)] @@ -32,11 +32,12 @@ pub struct Defaults { } impl Cfg { + /// # Errors pub async fn init(path: Option) -> MLE { let configfile = match path.clone() { Some(p) => p, None => dirs::config_dir() - .unwrap() + .ok_or(MLErr::new(EType::Other, "config_dir"))? .join("modlist") .join("config.toml") .to_string_lossy() @@ -70,8 +71,8 @@ impl Cfg { }; //Check versions let versionfile = format!("{}/versions.json", config.versions); - if let Ok(..) = File::open(&versionfile) { } else { - create_versions_dummy(&versionfile).await?; + if File::open(&versionfile).is_err() { + create_versions_dummy(&versionfile)?; check_game_versions(&versionfile, true).await?; } @@ -114,7 +115,7 @@ fn create_database(path: &str) -> MLE<()> { p.set_message("Create database"); File::create(path)?; - db_setup(path)?; + setup(path)?; p.finish_with_message(format!("Created database ({path})")); Ok(()) } @@ -129,7 +130,7 @@ fn create_cache(path: &str) -> MLE<()> { Ok(()) } -async fn create_versions_dummy(path: &str) -> MLE<()> { +fn create_versions_dummy(path: &str) -> MLE<()> { let p = ProgressBar::new(1); p.set_style(ProgressStyle::with_template("{wide_msg}").unwrap()); p.set_message("Create version file"); -- cgit v1.2.3