mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-04 04:17:10 +02:00
Make sure that we don't delete or cancel future tasks
This should already have been the case before, but there is no harm in adding another check.
This commit is contained in:
parent
e0821ad4b0
commit
6db90ba6cc
2 changed files with 30 additions and 2 deletions
|
@ -276,6 +276,28 @@ pub fn swap_index_uid_in_task(task: &mut Task, swap: (&str, &str)) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Remove references to task ids that are greater than the id of the given task.
|
||||
pub(crate) fn filter_out_references_to_newer_tasks(task: &mut Task) {
|
||||
let new_nbr_of_matched_tasks = match &mut task.kind {
|
||||
KindWithContent::TaskCancelation { tasks, .. }
|
||||
| KindWithContent::TaskDeletion { tasks, .. } => {
|
||||
tasks.remove_range(task.uid..);
|
||||
tasks.len()
|
||||
}
|
||||
_ => return,
|
||||
};
|
||||
match &mut task.details {
|
||||
Some(
|
||||
Details::TaskCancelation { matched_tasks, .. }
|
||||
| Details::TaskDeletion { matched_tasks, .. },
|
||||
) => {
|
||||
*matched_tasks = new_nbr_of_matched_tasks;
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
impl IndexScheduler {
|
||||
/// Asserts that the index scheduler's content is internally consistent.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue