From 47138c763290fe5274985358c365eac7c622cb63 Mon Sep 17 00:00:00 2001 From: mpostma Date: Thu, 4 Mar 2021 12:20:14 +0100 Subject: [PATCH] update settings --- src/data/updates.rs | 10 ++++------ src/index_controller/mod.rs | 10 ++++++++-- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/data/updates.rs b/src/data/updates.rs index 9f3e9b3fd..92bba693c 100644 --- a/src/data/updates.rs +++ b/src/data/updates.rs @@ -25,13 +25,11 @@ impl Data { pub async fn update_settings( &self, - _index: impl AsRef + Send + Sync + 'static, - _settings: Settings + index: String, + settings: Settings ) -> anyhow::Result { - todo!() - //let index_controller = self.index_controller.clone(); - //let update = tokio::task::spawn_blocking(move || index_controller.update_settings(index, settings)).await??; - //Ok(update.into()) + let update = self.index_controller.update_settings(index, settings).await?; + Ok(update.into()) } pub async fn clear_documents( diff --git a/src/index_controller/mod.rs b/src/index_controller/mod.rs index 54199c1d7..dd2dbd7cf 100644 --- a/src/index_controller/mod.rs +++ b/src/index_controller/mod.rs @@ -114,8 +114,14 @@ impl IndexController { todo!() } - fn update_settings(&self, index_uid: String, settings: Settings) -> anyhow::Result { - todo!() + pub async fn update_settings(&self, index_uid: String, settings: Settings) -> anyhow::Result { + let uuid = self.uuid_resolver.get_or_create(index_uid).await?; + let meta = UpdateMeta::Settings(settings); + // Nothing so send, drop the sender right away, as not to block the update actor. + let (_, receiver) = mpsc::channel(1); + + let status = self.update_handle.update(meta, receiver, uuid).await?; + Ok(status) } pub async fn create_index(&self, index_settings: IndexSettings) -> anyhow::Result {