Only remap the main database once

This commit is contained in:
Clément Renault 2023-11-28 14:27:30 +01:00
parent 7dd1226faf
commit d050c9b4ae
No known key found for this signature in database
GPG Key ID: F250A4C4E3AE5F5F

View File

@ -268,21 +268,10 @@ impl Index {
) -> heed::Result<()> { ) -> heed::Result<()> {
let mut txn = env.write_txn()?; let mut txn = env.write_txn()?;
// The db was just created, we update its metadata with the relevant information. // The db was just created, we update its metadata with the relevant information.
if main let main = main.remap_types::<Str, SerdeJson<OffsetDateTime>>();
.remap_types::<Str, SerdeJson<OffsetDateTime>>() if main.get(&txn, main_key::CREATED_AT_KEY)?.is_none() {
.get(&txn, main_key::CREATED_AT_KEY)? main.put(&mut txn, main_key::UPDATED_AT_KEY, &updated_at)?;
.is_none() main.put(&mut txn, main_key::CREATED_AT_KEY, &created_at)?;
{
main.remap_types::<Str, SerdeJson<OffsetDateTime>>().put(
&mut txn,
main_key::UPDATED_AT_KEY,
&updated_at,
)?;
main.remap_types::<Str, SerdeJson<OffsetDateTime>>().put(
&mut txn,
main_key::CREATED_AT_KEY,
&created_at,
)?;
txn.commit()?; txn.commit()?;
} }
Ok(()) Ok(())