diff --git a/Cargo.lock b/Cargo.lock index 5f1134379..cbae20c98 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1870,6 +1870,7 @@ dependencies = [ [[package]] name = "milli" version = "0.1.0" +source = "git+https://github.com/meilisearch/milli.git?rev=794fce7#794fce7bff3e3461a7f3954fd97f58f8232e5a8e" dependencies = [ "anyhow", "bstr", diff --git a/Cargo.toml b/Cargo.toml index aaf571ef3..9bc5e4d1d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -38,7 +38,7 @@ main_error = "0.1.0" meilisearch-error = { path = "../MeiliSearch/meilisearch-error" } meilisearch-tokenizer = { git = "https://github.com/meilisearch/Tokenizer.git", branch = "main" } memmap = "0.7.0" -milli = { path = "../milli/milli" } +milli = { git = "https://github.com/meilisearch/milli.git", rev = "794fce7" } mime = "0.3.16" once_cell = "1.5.2" rand = "0.7.3" diff --git a/src/data/updates.rs b/src/data/updates.rs index 3e3837861..dd74bc47f 100644 --- a/src/data/updates.rs +++ b/src/data/updates.rs @@ -59,10 +59,8 @@ impl Data { //Ok(()) } - #[inline] - pub fn get_update_status(&self, index: impl AsRef, uid: u64) -> anyhow::Result> { - todo!() - //self.index_controller.update_status(index, uid) + pub async fn get_update_status(&self, index: impl AsRef, uid: u64) -> anyhow::Result> { + self.index_controller.update_status(index.as_ref().to_string(), uid).await } pub async fn get_updates_status(&self, index: impl AsRef) -> anyhow::Result> { diff --git a/src/index_controller/mod.rs b/src/index_controller/mod.rs index 8eb1684a2..4606526c4 100644 --- a/src/index_controller/mod.rs +++ b/src/index_controller/mod.rs @@ -150,8 +150,13 @@ impl IndexController { todo!() } - fn update_status(&self, index: String, id: u64) -> anyhow::Result> { - todo!() + pub async fn update_status(&self, index: String, id: u64) -> anyhow::Result> { + let uuid = self.uuid_resolver + .resolve(index) + .await? + .context("index not found")?; + let result = self.update_handle.update_status(uuid, id).await?; + Ok(result) } pub async fn all_update_status(&self, index: String) -> anyhow::Result> { diff --git a/src/index_controller/update_actor.rs b/src/index_controller/update_actor.rs index b236df2a6..83f29c380 100644 --- a/src/index_controller/update_actor.rs +++ b/src/index_controller/update_actor.rs @@ -38,6 +38,11 @@ enum UpdateMsg { uuid: Uuid, ret: oneshot::Sender>>, }, + GetUpdate { + uuid: Uuid, + ret: oneshot::Sender>>, + id: u64, + } } struct UpdateActor { @@ -81,6 +86,9 @@ where Some(ListUpdates { uuid, ret }) => { let _ = ret.send(self.handle_list_updates(uuid).await); } , + Some(GetUpdate { uuid, ret, id }) => { + let _ = ret.send(self.handle_get_update(uuid, id).await); + } None => {} } } @@ -154,6 +162,17 @@ where }).await .map_err(|e| UpdateError::Error(Box::new(e)))? } + + + async fn handle_get_update(&self, uuid: Uuid, id: u64) -> Result> { + let store = self.store + .get(&uuid) + .await? + .ok_or(UpdateError::UnexistingIndex(uuid))?; + let result = store.meta(id) + .map_err(|e| UpdateError::Error(Box::new(e)))?; + Ok(result) + } } #[derive(Clone)] @@ -199,6 +218,13 @@ where let _ = self.sender.send(msg).await; receiver.await.expect("update actor killed.") } + + pub async fn update_status(&self, uuid: Uuid, id: u64) -> Result> { + let (ret, receiver) = oneshot::channel(); + let msg = UpdateMsg::GetUpdate { uuid, id, ret }; + let _ = self.sender.send(msg).await; + receiver.await.expect("update actor killed.") + } } struct MapUpdateStoreStore { diff --git a/src/routes/index.rs b/src/routes/index.rs index a8618d9dd..c9200f085 100644 --- a/src/routes/index.rs +++ b/src/routes/index.rs @@ -133,7 +133,7 @@ async fn get_update_status( data: web::Data, path: web::Path, ) -> Result { - let result = data.get_update_status(&path.index_uid, path.update_id); + let result = data.get_update_status(&path.index_uid, path.update_id).await; match result { Ok(Some(meta)) => { let json = serde_json::to_string(&meta).unwrap();