From 19ffe771d4b4c2c4690bc9dfb3fc640449761aef Mon Sep 17 00:00:00 2001 From: Klimperfix Date: Wed, 26 Mar 2025 14:31:15 +0100 Subject: Fix: create conf dir if it does not exist --- src/config.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/config.rs') diff --git a/src/config.rs b/src/config.rs index ce3b874..d554c58 100644 --- a/src/config.rs +++ b/src/config.rs @@ -16,9 +16,10 @@ ///// use std::{ - fs::File, + fs::{create_dir_all, File}, io::{stdin, Write}, path::PathBuf, + str::FromStr, }; use color_eyre::{eyre::Result, owo_colors::OwoColorize}; @@ -198,6 +199,13 @@ impl BibiConfig { } } + { + // Ignore any errors of this function, if something goes wrong creating a file will fail too. + let mut dirpath = PathBuf::from_str(path.unwrap()).unwrap_or_else(|_| PathBuf::new()); + dirpath.pop(); + let _ = create_dir_all(dirpath); + } + let cfg_file = File::create_new(path.unwrap()); match cfg_file { -- cgit v1.2.3