updates the current version of a collection
(
lmdb: &MetaDb,
version_hash: VersionNumber,
)
| 9 | |
| 10 | /// updates the current version of a collection |
| 11 | pub 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 |
| 36 | pub fn update_background_version( |
no test coverage detected