diff --git a/meilisearch-http/src/routes/dump.rs b/meilisearch-http/src/routes/dump.rs index 65cd7521f..b58552f27 100644 --- a/meilisearch-http/src/routes/dump.rs +++ b/meilisearch-http/src/routes/dump.rs @@ -8,6 +8,7 @@ use serde_json::json; use crate::analytics::Analytics; use crate::extractors::authentication::{policies::*, GuardedData}; use crate::extractors::sequential_extractor::SeqHandler; +use crate::task::SummarizedTaskView; pub fn configure(cfg: &mut web::ServiceConfig) { cfg.service(web::resource("").route(web::post().to(SeqHandler(create_dump)))) @@ -23,7 +24,7 @@ pub async fn create_dump( ) -> Result { analytics.publish("Dump Created".to_string(), json!({}), Some(&req)); - let res = meilisearch.create_dump().await?; + let res: SummarizedTaskView = meilisearch.register_dump_task().await?.into(); debug!("returns: {:?}", res); Ok(HttpResponse::Accepted().json(res)) diff --git a/meilisearch-http/src/task.rs b/meilisearch-http/src/task.rs index 56a181d29..c2399f141 100644 --- a/meilisearch-http/src/task.rs +++ b/meilisearch-http/src/task.rs @@ -24,6 +24,7 @@ enum TaskType { DocumentDeletion, SettingsUpdate, ClearAll, + Dump, } impl From for TaskType { @@ -43,6 +44,7 @@ impl From for TaskType { TaskContent::IndexDeletion => TaskType::IndexDeletion, TaskContent::IndexCreation { .. } => TaskType::IndexCreation, TaskContent::IndexUpdate { .. } => TaskType::IndexUpdate, + TaskContent::Dump { path } => TaskType::Dump, _ => unreachable!("unexpected task type"), } } @@ -216,7 +218,7 @@ impl From for TaskView { TaskType::IndexUpdate, Some(TaskDetails::IndexInfo { primary_key }), ), - TaskContent::Dump { path: _ } => todo!(), + TaskContent::Dump { path: _ } => (TaskType::Dump, None), }; // An event always has at least one event: "Created" diff --git a/meilisearch-lib/src/tasks/task_store/store.rs b/meilisearch-lib/src/tasks/task_store/store.rs index 912047d1e..902f80560 100644 --- a/meilisearch-lib/src/tasks/task_store/store.rs +++ b/meilisearch-lib/src/tasks/task_store/store.rs @@ -108,9 +108,10 @@ impl Store { pub fn put(&self, txn: &mut RwTxn, task: &Task) -> Result<()> { self.tasks.put(txn, &BEU64::new(task.id), task)?; - self.uids_task_ids - // TODO(marin): The index uid should be remaped to a task queue identifier here - .put(txn, &(&task.index_uid.as_ref().unwrap(), task.id), &())?; + // only add the task to the indexes index if it has an index_uid + if let Some(ref index_uid) = task.index_uid { + self.uids_task_ids.put(txn, &(&index_uid, task.id), &())?; + } Ok(()) }