MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / from_database

Method from_database

atomic-repository/src/redb_change_store/mod.rs:351–373  ·  view source on GitHub ↗

Use the store's tables in an already-open database, creating any that are missing.

(db: Arc<Database>)

Source from the content-addressed store, hash-verified

349 /// Use the store's tables in an already-open database, creating any that
350 /// are missing.
351 pub fn from_database(db: Arc<Database>) -> RedbStoreResult<Self> {
352 atomic_core::pristine::schema::check_schema_version(&db.begin_read()?)
353 .map_err(|error| RedbStoreError::Corrupt(error.to_string()))?;
354 {
355 let txn = db.begin_write()?;
356 {
357 let _ = txn.open_table(tables::CHANGE_META)?;
358 let _ = txn.open_table(tables::CHANGE_GRAPH)?;
359 let _ = txn.open_table(tables::CHANGE_SEMANTIC)?;
360 let _ = txn.open_table(tables::CONTENT_CHUNKS)?;
361 let _ = txn.open_table(tables::CHANGE_CHUNKS)?;
362 let _ = txn.open_table(tables::CHANGE_UNHASHED)?;
363 let _ = txn.open_table(tables::CHANGE_SIGNATURES)?;
364 Self::initialize_provenance_tables(&txn)?;
365 let _ = txn.open_table(tables::SESSION_LOG)?;
366 let _ = txn.open_table(tables::SESSION_LOG_IDS)?;
367 let _ = txn.open_table(tables::SESSION_LOG_INDEX)?;
368 }
369 txn.commit()?;
370 }
371
372 Ok(Self { db })
373 }
374
375 /// Get a reference to the underlying database.
376 pub(crate) fn db(&self) -> &Database {

Callers

nothing calls this directly

Calls 4

check_schema_versionFunction · 0.85
begin_readMethod · 0.80
begin_writeMethod · 0.80
commitMethod · 0.45

Tested by

no test coverage detected