Skip to content

Commit

Permalink
Merge pull request #197 from NotThorny/Config-Fix
Browse files Browse the repository at this point in the history
Fix crashing on null configs
  • Loading branch information
SpikeHD authored Aug 30, 2023
2 parents 09f5e74 + 843913a commit 1d4cf94
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src-tauri/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<bool>,
pub game_install_path: Option<String>,
Expand Down Expand Up @@ -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
}

0 comments on commit 1d4cf94

Please sign in to comment.