This commit is contained in:
amab8901 2022-12-21 14:28:00 +01:00
parent aa03e02fdc
commit d5978d11e1
3 changed files with 11 additions and 7 deletions

View File

@ -75,11 +75,10 @@ impl IndexMapper {
options.map_size(clamp_to_page_size(self.index_size));
options.max_readers(1024);
if date == None {
Ok(Index::new(options, path)?)
} else {
let (created, updated) = date.unwrap();
if let Some((created, updated)) = date {
Ok(Index::new_with_creation_dates(options, path, created, updated)?)
} else {
Ok(Index::new(options, path)?)
}
}

View File

@ -865,9 +865,12 @@ impl IndexScheduler {
}
/// Create a new index without any associated task.
pub fn create_raw_index(&self, name: &str) -> Result<Index> {
pub fn create_raw_index(
&self,
name: &str,
date: Option<(time::OffsetDateTime, time::OffsetDateTime)>,
) -> Result<Index> {
let wtxn = self.env.write_txn()?;
let date = Some((time::OffsetDateTime::now_utc(), time::OffsetDateTime::now_utc()));
let index = self.index_mapper.create_index(wtxn, name, date)?;
Ok(index)

View File

@ -277,7 +277,9 @@ fn import_dump(
let mut index_reader = index_reader?;
let metadata = index_reader.metadata();
log::info!("Importing index `{}`.", metadata.uid);
let index = index_scheduler.create_raw_index(&metadata.uid)?;
//let date = Some((time::OffsetDateTime::now_utc(), time::OffsetDateTime::now_utc()));
let date = dump_reader.date();
let index = index_scheduler.create_raw_index(&metadata.uid, date)?;
let mut wtxn = index.write_txn()?;