diff --git a/crates/common/src/config/inner.rs b/crates/common/src/config/inner.rs index 92528e261..6b4e99b36 100644 --- a/crates/common/src/config/inner.rs +++ b/crates/common/src/config/inner.rs @@ -69,7 +69,10 @@ impl Data { jmap_id_gen: id_generator.clone(), queue_id_gen: id_generator.clone(), span_id_gen: id_generator, - webadmin: WebAdminManager::new(), + webadmin: config + .value("webadmin.path") + .map(|path| WebAdminManager::new(path.into())) + .unwrap_or_default(), config_version: 0.into(), jmap_limiter: DashMap::with_capacity_and_hasher_and_shard_amount( capacity, diff --git a/crates/common/src/manager/webadmin.rs b/crates/common/src/manager/webadmin.rs index cf52a266e..27e3f1ac4 100644 --- a/crates/common/src/manager/webadmin.rs +++ b/crates/common/src/manager/webadmin.rs @@ -39,9 +39,9 @@ impl Resource { } impl WebAdminManager { - pub fn new() -> Self { + pub fn new(base_path: PathBuf) -> Self { Self { - bundle_path: TempDir::new(), + bundle_path: TempDir::new(base_path), routes: ArcSwap::from_pointee(Default::default()), } } @@ -171,9 +171,9 @@ pub struct TempDir { } impl TempDir { - pub fn new() -> TempDir { + pub fn new(path: PathBuf) -> TempDir { TempDir { - path: std::env::temp_dir().join(std::str::from_utf8(WEBADMIN_KEY).unwrap()), + path: path.join(std::str::from_utf8(WEBADMIN_KEY).unwrap()), } } @@ -193,13 +193,13 @@ fn unpack_error(err: std::io::Error) -> trc::Error { impl Default for WebAdminManager { fn default() -> Self { - Self::new() + Self::new(std::env::temp_dir()) } } impl Default for TempDir { fn default() -> Self { - Self::new() + Self::new(std::env::temp_dir()) } }