summaryrefslogtreecommitdiff
path: root/src/config.rs
diff options
context:
space:
mode:
authorfxqnlr <[email protected]>2024-09-04 09:56:42 +0200
committerfxqnlr <[email protected]>2024-09-04 09:56:42 +0200
commitf5e070cdf6628a5ebd981d373929802317104e24 (patch)
treee31c88371737e20b2cc79bf9ee0c1dbfdeb6e727 /src/config.rs
parent1d64516ed95266a4fc1f8a18652f99158a4004f1 (diff)
downloadmodlist-f5e070cdf6628a5ebd981d373929802317104e24.tar
modlist-f5e070cdf6628a5ebd981d373929802317104e24.tar.gz
modlist-f5e070cdf6628a5ebd981d373929802317104e24.zip
clippy --fix
Diffstat (limited to 'src/config.rs')
-rw-r--r--src/config.rs19
1 files changed, 8 insertions, 11 deletions
diff --git a/src/config.rs b/src/config.rs
index f0eb8f7..3538a69 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -70,12 +70,9 @@ impl Cfg {
70 }; 70 };
71 //Check versions 71 //Check versions
72 let versionfile = format!("{}/versions.json", config.versions); 72 let versionfile = format!("{}/versions.json", config.versions);
73 match File::open(&versionfile) { 73 if let Ok(..) = File::open(&versionfile) { } else {
74 Ok(..) => (), 74 create_versions_dummy(&versionfile).await?;
75 Err(..) => { 75 check_game_versions(&versionfile, true).await?;
76 create_versions_dummy(&versionfile).await?;
77 check_game_versions(&versionfile, true).await?;
78 }
79 } 76 }
80 77
81 Ok(config) 78 Ok(config)
@@ -94,7 +91,7 @@ fn create_config(path: &str) -> MLE<()> {
94 .to_string(); 91 .to_string();
95 let default_cfg = Cfg { 92 let default_cfg = Cfg {
96 data: cache_dir.clone(), 93 data: cache_dir.clone(),
97 cache: format!("{}/cache", cache_dir), 94 cache: format!("{cache_dir}/cache"),
98 versions: cache_dir, 95 versions: cache_dir,
99 defaults: Defaults { 96 defaults: Defaults {
100 modloader: Modloader::Fabric, 97 modloader: Modloader::Fabric,
@@ -107,7 +104,7 @@ fn create_config(path: &str) -> MLE<()> {
107 create_dir_all(path.split("config.toml").collect::<Vec<&str>>()[0])?; 104 create_dir_all(path.split("config.toml").collect::<Vec<&str>>()[0])?;
108 let mut file = File::create(path)?; 105 let mut file = File::create(path)?;
109 file.write_all(toml::to_string(&default_cfg)?.as_bytes())?; 106 file.write_all(toml::to_string(&default_cfg)?.as_bytes())?;
110 p.finish_with_message(format!("Created default config ({})", path)); 107 p.finish_with_message(format!("Created default config ({path})"));
111 Ok(()) 108 Ok(())
112} 109}
113 110
@@ -118,7 +115,7 @@ fn create_database(path: &str) -> MLE<()> {
118 115
119 File::create(path)?; 116 File::create(path)?;
120 db_setup(path)?; 117 db_setup(path)?;
121 p.finish_with_message(format!("Created database ({})", path)); 118 p.finish_with_message(format!("Created database ({path})"));
122 Ok(()) 119 Ok(())
123} 120}
124 121
@@ -128,7 +125,7 @@ fn create_cache(path: &str) -> MLE<()> {
128 p.set_message("Create cache"); 125 p.set_message("Create cache");
129 126
130 create_dir_all(path)?; 127 create_dir_all(path)?;
131 p.finish_with_message(format!("Created cache ({})", path)); 128 p.finish_with_message(format!("Created cache ({path})"));
132 Ok(()) 129 Ok(())
133} 130}
134 131
@@ -137,6 +134,6 @@ async fn create_versions_dummy(path: &str) -> MLE<()> {
137 p.set_style(ProgressStyle::with_template("{wide_msg}").unwrap()); 134 p.set_style(ProgressStyle::with_template("{wide_msg}").unwrap());
138 p.set_message("Create version file"); 135 p.set_message("Create version file");
139 File::create(path)?; 136 File::create(path)?;
140 p.finish_with_message(format!("Created version file ({})", path)); 137 p.finish_with_message(format!("Created version file ({path})"));
141 Ok(()) 138 Ok(())
142} 139}