make Task index_uid an option

Not all task relate to an index. Tasks that don't have an index_uid set
to None
This commit is contained in:
ad hoc 2022-05-16 19:50:45 +02:00
parent 9935db86c7
commit aa50acb031
No known key found for this signature in database
GPG key ID: 4F00A782990CC643
8 changed files with 79 additions and 35 deletions

View file

@ -187,7 +187,7 @@ impl From<(UpdateStatus, String, TaskId)> for Task {
// Dummy task
let mut task = Task {
id: task_id,
index_uid: IndexUid::new(uid).unwrap(),
index_uid: Some(IndexUid::new(uid).unwrap()),
content: TaskContent::IndexDeletion,
events: Vec::new(),
};

View file

@ -419,7 +419,7 @@ where
Update::UpdateIndex { primary_key } => TaskContent::IndexUpdate { primary_key },
};
let task = self.task_store.register(uid, content).await?;
let task = self.task_store.register(Some(uid), content).await?;
self.scheduler.read().await.notify();
Ok(task)
@ -569,7 +569,12 @@ where
// Check if the currently indexing update is from our index.
let is_indexing = processing_tasks
.first()
.map(|task| task.index_uid.as_str() == uid)
.map(|task| {
task.index_uid
.as_ref()
.map(|u| u.as_str() == uid)
.unwrap_or(false)
})
.unwrap_or_default();
let index = self.index_resolver.get_index(uid).await?;
@ -605,7 +610,7 @@ where
// Check if the currently indexing update is from our index.
stats.is_indexing = processing_tasks
.first()
.map(|p| p.index_uid.as_str() == index_uid)
.and_then(|p| p.index_uid.as_ref().map(|u| u.as_str() == index_uid))
.or(Some(false));
indexes.insert(index_uid, stats);