diff --git a/crates/common/src/manager/boot.rs b/crates/common/src/manager/boot.rs index 79079ff9..15fc349d 100644 --- a/crates/common/src/manager/boot.rs +++ b/crates/common/src/manager/boot.rs @@ -345,6 +345,20 @@ impl BootManager { Version = env!("CARGO_PKG_VERSION"), ); + // Webadmin auto-update + if config + .property_or_default::("webadmin.auto-update", "false") + .unwrap_or_default() + { + if let Err(err) = data.webadmin.update(&core).await { + trc::event!( + Resource(trc::ResourceEvent::Error), + Details = "Failed to update webadmin", + CausedBy = err + ); + } + } + // Build shared inner let (ipc, ipc_rxs) = build_ipc(); let inner = Arc::new(Inner { diff --git a/crates/common/src/manager/webadmin.rs b/crates/common/src/manager/webadmin.rs index 27e3f1ac..b49192d2 100644 --- a/crates/common/src/manager/webadmin.rs +++ b/crates/common/src/manager/webadmin.rs @@ -143,7 +143,7 @@ impl WebAdminManager { Ok(()) } - pub async fn update_and_unpack(&self, core: &Core) -> trc::Result<()> { + pub async fn update(&self, core: &Core) -> trc::Result<()> { let bytes = core .storage .config @@ -155,7 +155,11 @@ impl WebAdminManager { .reason(err) .details("Failed to download webadmin") })?; - core.storage.blob.put_blob(WEBADMIN_KEY, &bytes).await?; + core.storage.blob.put_blob(WEBADMIN_KEY, &bytes).await + } + + pub async fn update_and_unpack(&self, core: &Core) -> trc::Result<()> { + self.update(core).await?; self.unpack(&core.storage.blob).await } }