Fix always returning the default settings

This commit is contained in:
Imbris 2019-09-12 23:37:28 -04:00
parent b986603215
commit 28250c9f14

View File

@ -236,7 +236,7 @@ impl Settings {
if let Ok(file) = fs::File::open(&path) {
match ron::de::from_reader(file) {
Ok(s) => s,
Ok(s) => return s,
Err(e) => {
log::warn!("Failed to parse setting file! Fallback to default. {}", e);
// Rename the corrupted settings file
@ -249,6 +249,9 @@ impl Settings {
}
}
}
// This is reached if either:
// - The file can't be opened (presumably it doesn't exist)
// - Or there was an error parsing the file
let default_settings = Self::default();
default_settings.save_to_file_warn();
default_settings