From 30bdfc0870451a01f9b559d7165301c36ced79f1 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sat, 14 May 2022 14:54:03 +0100 Subject: [PATCH] nwtemplates: Split init_from_config and init_from_dir otterlib is going to call init_from_dir. Signed-off-by: Ian Jackson --- daemon/main.rs | 2 +- src/nwtemplates.rs | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/daemon/main.rs b/daemon/main.rs index 8540b1f7..f7ba4aaf 100644 --- a/daemon/main.rs +++ b/daemon/main.rs @@ -498,7 +498,7 @@ async fn main() -> Result<(),StartupError> { .context("check bundled-sources directory")?; } - nwtemplates::init()?; + nwtemplates::init_from_config()?; shapelib::load_global_libs(&config().shapelibs)?; c.lock_save_area()?; diff --git a/src/nwtemplates.rs b/src/nwtemplates.rs index a492bddf..1747957e 100644 --- a/src/nwtemplates.rs +++ b/src/nwtemplates.rs @@ -14,11 +14,14 @@ struct State { } #[throws(StartupError)] -pub fn init() { +pub fn init_from_config() { + init_from_dir(&config().nwtemplate_dir)?; +} + +#[throws(StartupError)] +pub fn init_from_dir(nwtemplate_dir: &str) { let mut guard = STATE.write(); assert!(guard.is_none()); - let config = config(); - let nwtemplate_dir = &config.nwtemplate_dir; let glob = format!("{}/*.tera", nwtemplate_dir); let tera = Tera::new(&glob) .map_err(|e| anyhow!("{}", e)) -- 2.30.2