From ca24693dbb8a1910db799e2d845b13eaf978599b Mon Sep 17 00:00:00 2001 From: xeruf <27jf@pm.me> Date: Mon, 11 Nov 2024 12:34:28 +0100 Subject: [PATCH] fix(main): auto-create config directory --- src/main.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index eddd529..2143416 100644 --- a/src/main.rs +++ b/src/main.rs @@ -170,8 +170,15 @@ async fn main() -> Result<()> { let config_dir = ProjectDirs::from("", "", "mostr") - .map(|p| p.config_dir().to_path_buf()) - .unwrap_or(PathBuf::new()); + .map(|p| { + let config = p.config_dir(); + or_warn!(fs::create_dir_all(config), "Could not create config directory"); + config.to_path_buf() + }) + .unwrap_or_else(|| { + warn!("Could not determine config directory, using current directory"); + PathBuf::new() + }); let keysfile = config_dir.join("key"); let relayfile = config_dir.join("relays");