From 7fc7eb7457a1bf96d49813277c6b02625ea46bfc Mon Sep 17 00:00:00 2001 From: many Date: Thu, 7 Oct 2021 15:14:25 +0200 Subject: [PATCH] Make sure to remove newly created index if uid is already taken --- .../src/index_controller/index_resolver/mod.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/meilisearch-lib/src/index_controller/index_resolver/mod.rs b/meilisearch-lib/src/index_controller/index_resolver/mod.rs index e68bd46f8..6400f0f19 100644 --- a/meilisearch-lib/src/index_controller/index_resolver/mod.rs +++ b/meilisearch-lib/src/index_controller/index_resolver/mod.rs @@ -98,8 +98,13 @@ where } let uuid = Uuid::new_v4(); let index = self.index_store.create(uuid, primary_key).await?; - self.index_uuid_store.insert(uid, uuid).await?; - Ok(index) + match self.index_uuid_store.insert(uid, uuid).await { + Err(e) => { + let _ = self.index_store.delete(uuid).await; + Err(e) + } + Ok(()) => Ok(index), + } } pub async fn list(&self) -> Result> {