MCPcopy Create free account
hub / github.com/cosdata/cosdata / update_current_version

Function update_current_version

src/models/meta_persist.rs:11–33  ·  view source on GitHub ↗

updates the current version of a collection

(
    lmdb: &MetaDb,
    version_hash: VersionNumber,
)

Source from the content-addressed store, hash-verified

9
10/// updates the current version of a collection
11pub fn update_current_version(
12 lmdb: &MetaDb,
13 version_hash: VersionNumber,
14) -> Result<(), WaCustomError> {
15 let env = lmdb.env.clone();
16 let db = lmdb.db;
17
18 let mut txn = env
19 .begin_rw_txn()
20 .map_err(|e| WaCustomError::DatabaseError(format!("Failed to begin transaction: {}", e)))?;
21
22 let key = key!(m:current_version);
23 let bytes = version_hash.to_le_bytes();
24
25 txn.put(db, &key, &bytes, WriteFlags::empty())
26 .map_err(|e| WaCustomError::DatabaseError(format!("Failed to put data: {}", e)))?;
27
28 txn.commit().map_err(|e| {
29 WaCustomError::DatabaseError(format!("Failed to commit transaction: {}", e))
30 })?;
31
32 Ok(())
33}
34
35/// updates the current version of a collection
36pub fn update_background_version(

Callers 3

create_collectionFunction · 0.85
commit_transactionFunction · 0.85
initMethod · 0.85

Calls 1

cloneMethod · 0.80

Tested by

no test coverage detected