mirror of
				https://github.com/meilisearch/meilisearch.git
				synced 2025-10-31 16:06:31 +00:00 
			
		
		
		
	Add a NoOp operation in index update
This commit is contained in:
		| @@ -28,7 +28,11 @@ pub fn upgrade_index_scheduler( | ||||
|     let current_minor = to.1; | ||||
|     let current_patch = to.2; | ||||
|  | ||||
|     let upgrade_functions: &[&dyn UpgradeIndexScheduler] = &[&ToCurrentNoOp {}]; | ||||
|     let upgrade_functions: &[&dyn UpgradeIndexScheduler] = &[ | ||||
|         // This is the last upgrade function, it will be called when the index is up to date. | ||||
|         // any other upgrade function should be added before this one. | ||||
|         &ToCurrentNoOp {}, | ||||
|     ]; | ||||
|  | ||||
|     let start = match from { | ||||
|         (1, 12, _) => 0, | ||||
|   | ||||
| @@ -8,6 +8,7 @@ use v1_13::{V1_13_0_To_V1_13_1, V1_13_1_To_Latest_V1_13}; | ||||
| use v1_14::Latest_V1_13_To_Latest_V1_14; | ||||
| use v1_15::Latest_V1_14_To_Latest_V1_15; | ||||
|  | ||||
| use crate::constants::{VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH}; | ||||
| use crate::progress::{Progress, VariableNameStep}; | ||||
| use crate::{Index, InternalError, Result}; | ||||
|  | ||||
| @@ -42,6 +43,9 @@ where | ||||
|         &V1_13_1_To_Latest_V1_13 {}, | ||||
|         &Latest_V1_13_To_Latest_V1_14 {}, | ||||
|         &Latest_V1_14_To_Latest_V1_15 {}, | ||||
|         // This is the last upgrade function, it will be called when the index is up to date. | ||||
|         // any other upgrade function should be added before this one. | ||||
|         &ToCurrentNoOp {}, | ||||
|     ]; | ||||
|  | ||||
|     let start = match from { | ||||
| @@ -51,7 +55,7 @@ where | ||||
|         (1, 13, _) => 4, | ||||
|         (1, 14, _) => 5, | ||||
|         // We must handle the current version in the match because in case of a failure some index may have been upgraded but not other. | ||||
|         (1, 15, _) => 5, | ||||
|         (1, 15, _) => 6, | ||||
|         (major, minor, patch) => { | ||||
|             return Err(InternalError::CannotUpgradeToVersion(major, minor, patch).into()) | ||||
|         } | ||||
| @@ -87,3 +91,22 @@ where | ||||
|  | ||||
|     Ok(regenerate_stats) | ||||
| } | ||||
|  | ||||
| #[allow(non_camel_case_types)] | ||||
| struct ToCurrentNoOp {} | ||||
|  | ||||
| impl UpgradeIndex for ToCurrentNoOp { | ||||
|     fn upgrade( | ||||
|         &self, | ||||
|         _wtxn: &mut RwTxn, | ||||
|         _index: &Index, | ||||
|         _original: (u32, u32, u32), | ||||
|         _progress: Progress, | ||||
|     ) -> Result<bool> { | ||||
|         Ok(false) | ||||
|     } | ||||
|  | ||||
|     fn target_version(&self) -> (u32, u32, u32) { | ||||
|         (VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH) | ||||
|     } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user