diff options
| author | Klimperfix | 2025-03-26 14:31:15 +0100 |
|---|---|---|
| committer | Klimperfix | 2025-03-26 14:31:15 +0100 |
| commit | 19ffe771d4b4c2c4690bc9dfb3fc640449761aef (patch) | |
| tree | ef14796784424b33c44ed4242419c66db09d602e /src/config.rs | |
| parent | 7f00fe5861cc5024fb41c4620357b47f5ad71019 (diff) | |
| download | bibiman-19ffe771d4b4c2c4690bc9dfb3fc640449761aef.tar.gz bibiman-19ffe771d4b4c2c4690bc9dfb3fc640449761aef.zip | |
Fix: create conf dir if it does not exist
Diffstat (limited to 'src/config.rs')
| -rw-r--r-- | src/config.rs | 10 |
1 files changed, 9 insertions, 1 deletions
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 { |
