diff options
author | fxqnlr <[email protected]> | 2024-09-04 11:12:04 +0200 |
---|---|---|
committer | fxqnlr <[email protected]> | 2024-09-04 11:12:04 +0200 |
commit | 6a91d0a864f9edd9d9fe50ca89ccbce4fc98e043 (patch) | |
tree | ae04cf34582f57699d12ac7b5b486ab065bf8d19 /src/config.rs | |
parent | f5e070cdf6628a5ebd981d373929802317104e24 (diff) | |
download | modlist-6a91d0a864f9edd9d9fe50ca89ccbce4fc98e043.tar modlist-6a91d0a864f9edd9d9fe50ca89ccbce4fc98e043.tar.gz modlist-6a91d0a864f9edd9d9fe50ca89ccbce4fc98e043.zip |
do nearly anything to shut clippy up
Diffstat (limited to 'src/config.rs')
-rw-r--r-- | src/config.rs | 13 |
1 files changed, 7 insertions, 6 deletions
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}; | |||
8 | use serde::{Deserialize, Serialize}; | 8 | use serde::{Deserialize, Serialize}; |
9 | 9 | ||
10 | use crate::{ | 10 | use crate::{ |
11 | check_game_versions, db::db_setup, error::MLE, Modloader, VersionLevel, | 11 | check_game_versions, db::setup, error::{EType, MLErr, MLE}, Modloader, VersionLevel, |
12 | }; | 12 | }; |
13 | 13 | ||
14 | #[derive(Debug, Clone, Serialize, Deserialize)] | 14 | #[derive(Debug, Clone, Serialize, Deserialize)] |
@@ -32,11 +32,12 @@ pub struct Defaults { | |||
32 | } | 32 | } |
33 | 33 | ||
34 | impl Cfg { | 34 | impl Cfg { |
35 | /// # Errors | ||
35 | pub async fn init(path: Option<String>) -> MLE<Self> { | 36 | pub async fn init(path: Option<String>) -> MLE<Self> { |
36 | let configfile = match path.clone() { | 37 | let configfile = match path.clone() { |
37 | Some(p) => p, | 38 | Some(p) => p, |
38 | None => dirs::config_dir() | 39 | None => dirs::config_dir() |
39 | .unwrap() | 40 | .ok_or(MLErr::new(EType::Other, "config_dir"))? |
40 | .join("modlist") | 41 | .join("modlist") |
41 | .join("config.toml") | 42 | .join("config.toml") |
42 | .to_string_lossy() | 43 | .to_string_lossy() |
@@ -70,8 +71,8 @@ impl Cfg { | |||
70 | }; | 71 | }; |
71 | //Check versions | 72 | //Check versions |
72 | let versionfile = format!("{}/versions.json", config.versions); | 73 | let versionfile = format!("{}/versions.json", config.versions); |
73 | if let Ok(..) = File::open(&versionfile) { } else { | 74 | if File::open(&versionfile).is_err() { |
74 | create_versions_dummy(&versionfile).await?; | 75 | create_versions_dummy(&versionfile)?; |
75 | check_game_versions(&versionfile, true).await?; | 76 | check_game_versions(&versionfile, true).await?; |
76 | } | 77 | } |
77 | 78 | ||
@@ -114,7 +115,7 @@ fn create_database(path: &str) -> MLE<()> { | |||
114 | p.set_message("Create database"); | 115 | p.set_message("Create database"); |
115 | 116 | ||
116 | File::create(path)?; | 117 | File::create(path)?; |
117 | db_setup(path)?; | 118 | setup(path)?; |
118 | p.finish_with_message(format!("Created database ({path})")); | 119 | p.finish_with_message(format!("Created database ({path})")); |
119 | Ok(()) | 120 | Ok(()) |
120 | } | 121 | } |
@@ -129,7 +130,7 @@ fn create_cache(path: &str) -> MLE<()> { | |||
129 | Ok(()) | 130 | Ok(()) |
130 | } | 131 | } |
131 | 132 | ||
132 | async fn create_versions_dummy(path: &str) -> MLE<()> { | 133 | fn create_versions_dummy(path: &str) -> MLE<()> { |
133 | let p = ProgressBar::new(1); | 134 | let p = ProgressBar::new(1); |
134 | p.set_style(ProgressStyle::with_template("{wide_msg}").unwrap()); | 135 | p.set_style(ProgressStyle::with_template("{wide_msg}").unwrap()); |
135 | p.set_message("Create version file"); | 136 | p.set_message("Create version file"); |