forked from janek/mostr
1
0
Fork 0

fix(main): auto-create config directory

This commit is contained in:
xeruf 2024-11-11 12:34:28 +01:00
parent ed72bcebcf
commit ca24693dbb
1 changed files with 9 additions and 2 deletions

View File

@ -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");