removed async on load

This commit is contained in:
poslop
2024-06-06 03:33:12 -05:00
parent faa3f0eff2
commit 652d6053b7
5 changed files with 45 additions and 46 deletions

View File

@@ -1,3 +1,3 @@
cslol_dir = "WHY U FUCK NO WORK"
cslol_dir = "WHY U RK"
wad_dir = ""
extract_dir = ""

View File

@@ -1,4 +1,4 @@
use tokio::fs;
use std::fs;
use serde::{Deserialize, Serialize};
@@ -12,23 +12,21 @@ pub struct Config {
#[tauri::command]
pub async fn init_config() {
// Check if the config file exists asynchronously
if fs::metadata("config.toml").await.is_err() {
if fs::metadata("config.toml").is_err() {
let config = Config {
cslol_dir: "".to_string(),
wad_dir: "C:\\Riot Games\\League of Legends\\Game\\DATA\\FINAL\\Champions".to_string(),
extract_dir: "".to_string(),
};
write_config(config).await; // Call the async version of write_config
write_config(config).await;
}
}
#[tauri::command]
pub async fn load_config() -> Config {
// Read the config file asynchronously
let config = fs::read_to_string("config.toml").await
pub fn load_config() -> Config {
let config = fs::read_to_string("config.toml")
.expect("Failed to read config.toml file");
// Parse the config synchronously as before (no async TOML parser by default)
print!("COMMAND \n{}", config);
toml::from_str(&config)
.expect("Failed to parse config.toml file")
}
@@ -40,6 +38,6 @@ pub async fn write_config(config: Config) {
.expect("Failed to serialize config");
// Write the config file asynchronously
fs::write("config.toml", config_content).await
fs::write("config.toml", config_content)
.expect("Failed to write to config.toml file");
}