From: Ian Jackson Date: Sat, 14 May 2022 13:54:03 +0000 (+0100) Subject: nwtemplates: Split init_from_config and init_from_dir X-Git-Tag: otter-1.1.0~189 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=30bdfc0870451a01f9b559d7165301c36ced79f1;p=otter.git nwtemplates: Split init_from_config and init_from_dir otterlib is going to call init_from_dir. Signed-off-by: Ian Jackson --- 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))