Skip to content

Commit 454bec4

Browse files
committed
fix(commands): if dbd-overlay-config doesn't exist as a directory, make it first
1 parent 21c06f3 commit 454bec4

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

src-tauri/src/commands.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use futures_util::{SinkExt, StreamExt};
77
use serde::{Deserialize, Serialize};
88
use serde_json::Value;
99
use sha2::{Digest, Sha256};
10+
use tokio::fs::create_dir;
1011
use std::fs;
1112
use std::io::Read;
1213
use std::sync::Arc;
@@ -134,7 +135,13 @@ pub async fn save_file_as(app: AppHandle, content: String) -> Result<Option<Open
134135
#[command]
135136
pub async fn load_default_config(handle: AppHandle) -> Result<Option<OpenResult>, String> {
136137
let base = dirs::data_local_dir().ok_or("Could not resolve %LOCALAPPDATA%")?;
137-
let path = base.join("dbd-overlay-config").join("config.ini");
138+
let mut path = base.join("dbd-overlay-config");
139+
140+
if !path.exists() {
141+
let _ = create_dir(&path).await;
142+
}
143+
144+
path = path.join("config.ini");
138145

139146
let mut content = String::new();
140147

@@ -148,7 +155,7 @@ pub async fn load_default_config(handle: AppHandle) -> Result<Option<OpenResult>
148155

149156
let mut static_config = String::new();
150157

151-
fs::File::open(&static_config_path)
158+
let _ = fs::File::open(&static_config_path)
152159
.map_err(|e| format!("Error while reading static config: {}", e))
153160
.unwrap()
154161
.read_to_string(&mut static_config);

0 commit comments

Comments
 (0)