mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-03 20:07:09 +02:00
Upgrade supports cancelling
This commit is contained in:
parent
b82dda2d0d
commit
121c1ac1dd
2 changed files with 16 additions and 3 deletions
|
@ -23,12 +23,16 @@ trait UpgradeIndex {
|
|||
}
|
||||
|
||||
/// Return true if the cached stats of the index must be regenerated
|
||||
pub fn upgrade(
|
||||
pub fn upgrade<MSP>(
|
||||
wtxn: &mut RwTxn,
|
||||
index: &Index,
|
||||
db_version: (u32, u32, u32),
|
||||
must_stop_processing: MSP,
|
||||
progress: Progress,
|
||||
) -> Result<bool> {
|
||||
) -> Result<bool>
|
||||
where
|
||||
MSP: Fn() -> bool + Sync,
|
||||
{
|
||||
let from = index.get_version(wtxn)?.unwrap_or(db_version);
|
||||
let upgrade_functions: &[&dyn UpgradeIndex] = &[
|
||||
&V1_12_To_V1_12_3 {},
|
||||
|
@ -56,6 +60,9 @@ pub fn upgrade(
|
|||
let mut current_version = from;
|
||||
let mut regenerate_stats = false;
|
||||
for (i, upgrade) in upgrade_path.iter().enumerate() {
|
||||
if (must_stop_processing)() {
|
||||
return Err(crate::Error::InternalError(InternalError::AbortedIndexation));
|
||||
}
|
||||
let target = upgrade.target_version();
|
||||
progress.update_progress(VariableNameStep::<UpgradeVersion>::new(
|
||||
format!(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue