From 843913a6641efd55dc2bc8e907c96e2dff6be000 Mon Sep 17 00:00:00 2001 From: Thoronium <107363768+NotThorny@users.noreply.github.com> Date: Tue, 29 Aug 2023 15:17:31 -0600 Subject: [PATCH] Fix crashing on null configs --- src-tauri/src/config.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src-tauri/src/config.rs b/src-tauri/src/config.rs index 864146f..b793bef 100644 --- a/src-tauri/src/config.rs +++ b/src-tauri/src/config.rs @@ -3,7 +3,7 @@ use std::path::PathBuf; use std::string::String; // Config may not exist, or may be old, so it's okay if these are optional -#[derive(Serialize, Deserialize, Debug)] +#[derive(Serialize, Deserialize, Debug, Default)] pub struct Configuration { pub toggle_grasscutter: Option, pub game_install_path: Option, @@ -41,7 +41,7 @@ pub fn config_path() -> PathBuf { pub fn get_config() -> Configuration { let path = config_path(); let config = std::fs::read_to_string(path).unwrap_or("{}".to_string()); - let config: Configuration = serde_json::from_str(&config).unwrap(); + let config: Configuration = serde_json::from_str(&config).unwrap_or_default(); config }