diff --git a/src/index_controller/local_index_controller/index_store.rs b/src/index_controller/local_index_controller/index_store.rs index eca18444f..937a0cac0 100644 --- a/src/index_controller/local_index_controller/index_store.rs +++ b/src/index_controller/local_index_controller/index_store.rs @@ -192,7 +192,7 @@ impl IndexStore { Ok((index, update_store)) } - /// Same a get or create, but returns an error if the index already exists. + /// Same as `get_or_create`, but returns an error if the index already exists. pub fn create_index( &self, name: impl AsRef, @@ -219,23 +219,17 @@ impl IndexStore { /// Returns each index associated with it's metadata; pub fn list_indexes(&self) -> anyhow::Result> { let txn = self.env.read_txn()?; - let indexes = self.name_to_uuid + let metas = self.name_to_uuid .iter(&txn)? .filter_map(|entry| entry - .map_err(|e| { - error!("error decoding entry while listing indexes: {}", e); - e - }) - .ok()) - .map(|(name, uuid)| { - let meta = self.uuid_to_index_meta - .get(&txn, &uuid) - .ok() - .flatten() - .unwrap_or_else(|| panic!("corrupted database, index {} should exist.", name)); - (name.to_owned(), meta) - }) - .collect(); + .map_err(|e| { error!("error decoding entry while listing indexes: {}", e); e }).ok()); + let mut indexes = Vec::new(); + for (name, uuid) in metas { + let meta = self.uuid_to_index_meta + .get(&txn, &uuid)? + .unwrap_or_else(|| panic!("corrupted database, index {} should exist.", name)); + indexes.push((name.to_owned(), meta)); + } Ok(indexes) } } diff --git a/src/index_controller/mod.rs b/src/index_controller/mod.rs index 720c52cdc..13ecc1486 100644 --- a/src/index_controller/mod.rs +++ b/src/index_controller/mod.rs @@ -25,7 +25,7 @@ pub struct IndexMetadata { uuid: Uuid, created_at: DateTime, updated_at: DateTime, - pub primary_key: Option, + primary_key: Option, } #[derive(Debug, Clone, Serialize, Deserialize)]