config: save updated config on load
This commit is contained in:
parent
7e664848dd
commit
93aeff17cb
1 changed files with 4 additions and 1 deletions
|
@ -14,11 +14,14 @@ pub(super) struct ConfigWatcher {
|
|||
}
|
||||
|
||||
pub fn init_config(path: impl AsRef<std::path::Path>) -> Option<ConfigWatcher> {
|
||||
let _ = CONFIG_PATH.get_or_init(|| path.as_ref().to_path_buf());
|
||||
log::trace!("loading config...");
|
||||
let config = Config::load(&path).unwrap();
|
||||
if let Err(e) = config.save() {
|
||||
log::warn!("couldn't save updated config: {e:?}");
|
||||
}
|
||||
log::trace!("watching config for changes...");
|
||||
let config_watcher = ConfigWatcher::new(&path);
|
||||
let _ = CONFIG_PATH.get_or_init(|| path.as_ref().to_path_buf());
|
||||
CONFIG.set(tokio::sync::RwLock::new(config)).unwrap();
|
||||
|
||||
config_watcher
|
||||
|
|
Loading…
Add table
Reference in a new issue