review changes

This commit is contained in:
mpostma 2021-06-10 15:55:44 +02:00
parent eb7616ca0f
commit 3ef0830c5d
6 changed files with 9 additions and 7 deletions

View File

@ -81,7 +81,7 @@ impl UpdateHandler {
primary_key.as_deref(),
),
ClearDocuments => index.clear_documents(update_builder),
DeleteDocuments { documents } => index.delete_documents(documents.to_vec(), update_builder),
DeleteDocuments { ids } => index.delete_documents(ids, update_builder),
Settings(settings) => index.update_settings(&settings.clone().check(), update_builder),
};

View File

@ -298,7 +298,7 @@ impl Index {
pub fn delete_documents(
&self,
document_ids: Vec<String>,
document_ids: &[String],
update_builder: UpdateBuilder,
) -> anyhow::Result<UpdateResult> {
let mut txn = self.write_txn()?;

View File

@ -40,6 +40,8 @@ impl MapIndexStore {
#[async_trait::async_trait]
impl IndexStore for MapIndexStore {
async fn create(&self, uuid: Uuid, primary_key: Option<String>) -> IndexResult<Index> {
// We need to keep the lock until we are sure the db file has been opened correclty, to
// ensure that another db is not created at the same time.
let mut lock = self.index_store.write().await;
if let Some(index) = lock.get(&uuid) {

View File

@ -203,7 +203,7 @@ impl IndexController {
documents: Vec<String>,
) -> anyhow::Result<UpdateStatus> {
let uuid = self.uuid_resolver.get(uid).await?;
let meta = UpdateMeta::DeleteDocuments { documents };
let meta = UpdateMeta::DeleteDocuments { ids: documents };
let (_, receiver) = mpsc::channel(1);
let status = self.update_handle.update(meta, receiver, uuid).await?;
Ok(status)

View File

@ -174,7 +174,7 @@ impl UpdateStore {
Ok(Some(_)) => (),
Ok(None) => break,
Err(e) => {
error!("Fatal error while processing update that requires the update store to shutdown: {}", e);
error!("Fatal error while processing an update that requires the update store to shutdown: {}", e);
must_exit.store(true, Ordering::SeqCst);
break 'outer;
}
@ -185,9 +185,9 @@ impl UpdateStore {
}
}
}
});
error!("Update store loop exited.");
error!("Update store loop exited.");
});
Ok(update_store)
}

View File

@ -24,7 +24,7 @@ pub enum UpdateMeta {
},
ClearDocuments,
DeleteDocuments {
documents: Vec<String>
ids: Vec<String>
},
Settings(Settings<Unchecked>),
}