allow tests to pass if global config dir can't be found or made
This commit is contained in:
parent
a1c8b4a8db
commit
41b31860ca
@ -7,7 +7,7 @@ use serde::Deserialize;
|
|||||||
use std::fs::{File, read_dir};
|
use std::fs::{File, read_dir};
|
||||||
use std::io::Read;
|
use std::io::Read;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::{fs, str};
|
use std::str;
|
||||||
|
|
||||||
#[derive(RustEmbed)]
|
#[derive(RustEmbed)]
|
||||||
#[folder = "formats/"]
|
#[folder = "formats/"]
|
||||||
@ -95,19 +95,19 @@ impl FormatConfig {
|
|||||||
config.get_file_config(config_path)?;
|
config.get_file_config(config_path)?;
|
||||||
|
|
||||||
let global_dir = match global_config_path {
|
let global_dir = match global_config_path {
|
||||||
Some(g) => g.clone(),
|
Some(g) => Some(g.clone()),
|
||||||
None => {
|
None => {
|
||||||
let app_dirs = AppDirs::new(Some("formaty"), true).unwrap();
|
if let Some(app_dirs) = AppDirs::new(Some("formaty"), true)
|
||||||
|
&& app_dirs.config_dir.exists()
|
||||||
if !app_dirs.config_dir.exists() {
|
{
|
||||||
fs::create_dir(&app_dirs.config_dir)?;
|
Some(app_dirs.config_dir)
|
||||||
|
} else {
|
||||||
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
app_dirs.config_dir
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
config.parse_directory(&Some(global_dir))?;
|
config.parse_directory(&global_dir)?;
|
||||||
|
|
||||||
Ok(config)
|
Ok(config)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user