Make sure to remove newly created index if uid is already taken

This commit is contained in:
many 2021-10-07 15:14:25 +02:00
parent 5e3e108143
commit 7fc7eb7457
No known key found for this signature in database
GPG Key ID: 2CEF23B75189EACA

View File

@ -98,8 +98,13 @@ where
} }
let uuid = Uuid::new_v4(); let uuid = Uuid::new_v4();
let index = self.index_store.create(uuid, primary_key).await?; let index = self.index_store.create(uuid, primary_key).await?;
self.index_uuid_store.insert(uid, uuid).await?; match self.index_uuid_store.insert(uid, uuid).await {
Ok(index) Err(e) => {
let _ = self.index_store.delete(uuid).await;
Err(e)
}
Ok(()) => Ok(index),
}
} }
pub async fn list(&self) -> Result<Vec<(String, Index)>> { pub async fn list(&self) -> Result<Vec<(String, Index)>> {