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

Method from_database

atomic-repository/src/redb_change_store/mod.rs:322–344  ·  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

320 /// Use the store's tables in an already-open database, creating any that
321 /// are missing.
322 pub fn from_database(db: Arc<Database>) -> RedbStoreResult<Self> {
323 atomic_core::pristine::schema::check_schema_version(&db.begin_read()?)
324 .map_err(|error| RedbStoreError::Corrupt(error.to_string()))?;
325 {
326 let txn = db.begin_write()?;
327 {
328 let _ = txn.open_table(tables::CHANGE_META)?;
329 let _ = txn.open_table(tables::CHANGE_GRAPH)?;
330 let _ = txn.open_table(tables::CHANGE_SEMANTIC)?;
331 let _ = txn.open_table(tables::CONTENT_CHUNKS)?;
332 let _ = txn.open_table(tables::CHANGE_CHUNKS)?;
333 let _ = txn.open_table(tables::CHANGE_UNHASHED)?;
334 let _ = txn.open_table(tables::CHANGE_SIGNATURES)?;
335 Self::initialize_provenance_tables(&txn)?;
336 let _ = txn.open_table(tables::SESSION_LOG)?;
337 let _ = txn.open_table(tables::SESSION_LOG_IDS)?;
338 let _ = txn.open_table(tables::SESSION_LOG_INDEX)?;
339 }
340 txn.commit()?;
341 }
342
343 Ok(Self { db })
344 }
345
346 /// Get a reference to the underlying database.
347 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