diff --git a/src/config.rs b/src/config.rs index df67e217d..2c59d6435 100644 --- a/src/config.rs +++ b/src/config.rs @@ -120,6 +120,10 @@ pub enum Config { } impl Context { + pub async fn config_exists(&self, key: Config) -> bool { + self.sql.get_raw_config(self, key).await.is_some() + } + /// Get a configuration key. Returns `None` if no value is set, and no default value found. pub async fn get_config(&self, key: Config) -> Option { let value = match key { diff --git a/src/configure/mod.rs b/src/configure/mod.rs index 1002cd7cb..7b45e5386 100644 --- a/src/configure/mod.rs +++ b/src/configure/mod.rs @@ -70,16 +70,20 @@ impl Context { async fn inner_configure(&self) -> Result<()> { info!(self, "Configure ..."); - let was_configured_before = self.is_configured().await; let mut param = LoginParam::from_database(self, "").await; let success = configure(self, &mut param).await; if let Some(provider) = provider::get_provider_info(¶m.addr) { - if !was_configured_before { - if let Some(config_defaults) = &provider.config_defaults { - for def in config_defaults.iter() { + if let Some(config_defaults) = &provider.config_defaults { + for def in config_defaults.iter() { + if !self.config_exists(def.key).await { info!(self, "apply config_defaults {}={}", def.key, def.value); self.set_config(def.key, Some(def.value)).await?; + } else { + info!( + self, + "skip already set config_defaults {}={}", def.key, def.value + ); } } }