refactor: move base path config + documentation

This commit is contained in:
Thomas Frans
2023-05-27 14:15:55 +02:00
committed by Henrik Friedrichsen
parent 6be45ece90
commit 04cbe8ac20
4 changed files with 29 additions and 19 deletions

View File

@@ -254,6 +254,7 @@ impl Config {
crate::theme::load(theme)
}
/// Reload the configuration file.
pub fn reload(&self) {
let cfg = load(&self.filename.to_string_lossy()).expect("could not reload config");
*self.values.write().expect("can't writelock config values") = cfg
@@ -327,3 +328,13 @@ pub fn cache_path(file: &str) -> PathBuf {
pb.push(file);
pb
}
/// Set the configuration base path. All configuration files are read/written relative to this path.
pub fn set_configuration_base_path(base_path: Option<PathBuf>) {
if let Some(basepath) = base_path {
if !basepath.exists() {
fs::create_dir_all(&basepath).expect("could not create basepath directory");
}
*BASE_PATH.write().unwrap() = Some(basepath);
}
}