Move the creation date initialization into a function

This commit is contained in:
Clément Renault 2021-04-21 11:48:23 +02:00 committed by Kerollmops
parent 49bee2ebc5
commit df7a32e3d0
No known key found for this signature in database
GPG Key ID: 92ADA4E935E71FA4

View File

@ -81,16 +81,7 @@ impl Index {
let field_id_docid_facet_values = env.create_database(Some("field-id-docid-facet-values"))?; let field_id_docid_facet_values = env.create_database(Some("field-id-docid-facet-values"))?;
let documents = env.create_database(Some("documents"))?; let documents = env.create_database(Some("documents"))?;
{ Index::initialize_creation_dates(&env, main)?;
let mut txn = env.write_txn()?;
// The db was just created, we update its metadata with the relevant information.
if main.get::<_, Str, SerdeJson<DateTime<Utc>>>(&txn, CREATED_AT_KEY)?.is_none() {
let now = Utc::now();
main.put::<_, Str, SerdeJson<DateTime<Utc>>>(&mut txn, UPDATED_AT_KEY, &now)?;
main.put::<_, Str, SerdeJson<DateTime<Utc>>>(&mut txn, CREATED_AT_KEY, &now)?;
txn.commit()?;
}
}
Ok(Index { Ok(Index {
env, env,