Get date from IndexMetaData

This commit is contained in:
amab8901 2022-12-22 11:46:17 +01:00
parent df176aaf01
commit 9a39c4e40d
3 changed files with 6 additions and 11 deletions

View File

@ -9,6 +9,7 @@ use meilisearch_types::heed::types::Str;
use meilisearch_types::heed::{Database, Env, EnvOpenOptions, RoTxn, RwTxn}; use meilisearch_types::heed::{Database, Env, EnvOpenOptions, RoTxn, RwTxn};
use meilisearch_types::milli::update::IndexerConfig; use meilisearch_types::milli::update::IndexerConfig;
use meilisearch_types::milli::Index; use meilisearch_types::milli::Index;
use time::OffsetDateTime;
use uuid::Uuid; use uuid::Uuid;
use self::IndexStatus::{Available, BeingDeleted}; use self::IndexStatus::{Available, BeingDeleted};
@ -69,7 +70,7 @@ impl IndexMapper {
fn create_or_open_index( fn create_or_open_index(
&self, &self,
path: &Path, path: &Path,
date: Option<(time::OffsetDateTime, time::OffsetDateTime)>, date: Option<(OffsetDateTime, OffsetDateTime)>,
) -> Result<Index> { ) -> Result<Index> {
let mut options = EnvOpenOptions::new(); let mut options = EnvOpenOptions::new();
options.map_size(clamp_to_page_size(self.index_size)); options.map_size(clamp_to_page_size(self.index_size));
@ -87,7 +88,7 @@ impl IndexMapper {
&self, &self,
mut wtxn: RwTxn, mut wtxn: RwTxn,
name: &str, name: &str,
date: Option<(time::OffsetDateTime, time::OffsetDateTime)>, date: Option<(OffsetDateTime, OffsetDateTime)>,
) -> Result<Index> { ) -> Result<Index> {
match self.index(&wtxn, name) { match self.index(&wtxn, name) {
Ok(index) => { Ok(index) => {

View File

@ -693,7 +693,7 @@ impl IndexScheduler {
let mut task = Task { let mut task = Task {
uid: self.next_task_id(&wtxn)?, uid: self.next_task_id(&wtxn)?,
enqueued_at: time::OffsetDateTime::now_utc(), enqueued_at: OffsetDateTime::now_utc(),
started_at: None, started_at: None,
finished_at: None, finished_at: None,
error: None, error: None,
@ -868,11 +868,10 @@ impl IndexScheduler {
pub fn create_raw_index( pub fn create_raw_index(
&self, &self,
name: &str, name: &str,
date: Option<(time::OffsetDateTime, time::OffsetDateTime)>, date: Option<(OffsetDateTime, OffsetDateTime)>,
) -> Result<Index> { ) -> Result<Index> {
let wtxn = self.env.write_txn()?; let wtxn = self.env.write_txn()?;
let index = self.index_mapper.create_index(wtxn, name, date)?; let index = self.index_mapper.create_index(wtxn, name, date)?;
Ok(index) Ok(index)
} }

View File

@ -289,13 +289,8 @@ fn import_dump(
let mut index_reader = index_reader?; let mut index_reader = index_reader?;
let metadata = index_reader.metadata(); let metadata = index_reader.metadata();
log::info!("Importing index `{}`.", metadata.uid); log::info!("Importing index `{}`.", metadata.uid);
let date;
if let Some(dump_reader_date) = dump_reader.date() {
date = Some((dump_reader_date, dump_reader_date));
} else {
date = Some((time::OffsetDateTime::now_utc(), time::OffsetDateTime::now_utc()));
}
let date = Some((metadata.created_at, metadata.updated_at));
let index = index_scheduler.create_raw_index(&metadata.uid, date)?; let index = index_scheduler.create_raw_index(&metadata.uid, date)?;
let mut wtxn = index.write_txn()?; let mut wtxn = index.write_txn()?;