mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-03 11:57:07 +02:00
fix the bad index version on opening
This commit is contained in:
parent
4f21ee6c66
commit
7197ced673
16 changed files with 31 additions and 21 deletions
|
@ -178,6 +178,7 @@ impl Index {
|
|||
path: P,
|
||||
created_at: time::OffsetDateTime,
|
||||
updated_at: time::OffsetDateTime,
|
||||
creation: bool,
|
||||
) -> Result<Index> {
|
||||
use db_name::*;
|
||||
|
||||
|
@ -253,7 +254,7 @@ impl Index {
|
|||
embedder_category_id,
|
||||
documents,
|
||||
};
|
||||
if this.get_version(&wtxn)?.is_none() {
|
||||
if this.get_version(&wtxn)?.is_none() && creation {
|
||||
this.put_version(
|
||||
&mut wtxn,
|
||||
(
|
||||
|
@ -270,9 +271,13 @@ impl Index {
|
|||
Ok(this)
|
||||
}
|
||||
|
||||
pub fn new<P: AsRef<Path>>(options: heed::EnvOpenOptions, path: P) -> Result<Index> {
|
||||
pub fn new<P: AsRef<Path>>(
|
||||
options: heed::EnvOpenOptions,
|
||||
path: P,
|
||||
creation: bool,
|
||||
) -> Result<Index> {
|
||||
let now = time::OffsetDateTime::now_utc();
|
||||
Self::new_with_creation_dates(options, path, now, now)
|
||||
Self::new_with_creation_dates(options, path, now, now, creation)
|
||||
}
|
||||
|
||||
fn set_creation_dates(
|
||||
|
@ -1802,7 +1807,7 @@ pub(crate) mod tests {
|
|||
let mut options = EnvOpenOptions::new();
|
||||
options.map_size(size);
|
||||
let _tempdir = TempDir::new_in(".").unwrap();
|
||||
let inner = Index::new(options, _tempdir.path()).unwrap();
|
||||
let inner = Index::new(options, _tempdir.path(), true).unwrap();
|
||||
let indexer_config = IndexerConfig::default();
|
||||
let index_documents_config = IndexDocumentsConfig::default();
|
||||
Self { inner, indexer_config, index_documents_config, _tempdir }
|
||||
|
|
|
@ -17,7 +17,7 @@ pub fn setup_search_index_with_criteria(criteria: &[Criterion]) -> Index {
|
|||
let path = tempfile::tempdir().unwrap();
|
||||
let mut options = EnvOpenOptions::new();
|
||||
options.map_size(10 * 1024 * 1024); // 10 MB
|
||||
let index = Index::new(options, &path).unwrap();
|
||||
let index = Index::new(options, &path, true).unwrap();
|
||||
|
||||
let mut wtxn = index.write_txn().unwrap();
|
||||
let config = IndexerConfig::default();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue