fix index creation bug

This commit is contained in:
mpostma
2021-06-09 11:52:36 +02:00
parent 9f40896f4a
commit 1a65eed724
8 changed files with 16 additions and 56 deletions

View File

@ -40,6 +40,11 @@ impl MapIndexStore {
#[async_trait::async_trait]
impl IndexStore for MapIndexStore {
async fn create(&self, uuid: Uuid, primary_key: Option<String>) -> IndexResult<Index> {
let mut lock = self.index_store.write().await;
if let Some(index) = lock.get(&uuid) {
return Ok(index.clone())
}
let path = self.path.join(format!("index-{}", uuid));
if path.exists() {
return Err(IndexError::IndexAlreadyExists);
@ -57,7 +62,7 @@ impl IndexStore for MapIndexStore {
})
.await??;
self.index_store.write().await.insert(uuid, index.clone());
lock.insert(uuid, index.clone());
Ok(index)
}