aboutsummaryrefslogtreecommitdiff
path: root/src/db/counted_tree_hack.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2023-09-21 15:32:25 +0200
committerAlex Auvolat <alex@adnab.me>2023-09-21 15:35:31 +0200
commitf97168f80567f43e15cf236092703e6ae5d8dc2e (patch)
treeca9b06fa1d9bf3af9b33c5db0a8c09a53b403fa9 /src/db/counted_tree_hack.rs
parentfd7d8fec59c617b40e480ff855894cf35fdcfb40 (diff)
downloadgarage-f97168f80567f43e15cf236092703e6ae5d8dc2e.tar.gz
garage-f97168f80567f43e15cf236092703e6ae5d8dc2e.zip
garage_db: refactor transactions and add on_commit mechanism
Diffstat (limited to 'src/db/counted_tree_hack.rs')
-rw-r--r--src/db/counted_tree_hack.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/db/counted_tree_hack.rs b/src/db/counted_tree_hack.rs
index bbe943a2..a4ce12e0 100644
--- a/src/db/counted_tree_hack.rs
+++ b/src/db/counted_tree_hack.rs
@@ -85,7 +85,7 @@ impl CountedTree {
let old_some = expected_old.is_some();
let new_some = new.is_some();
- let tx_res = self.0.tree.db().transaction(|mut tx| {
+ let tx_res = self.0.tree.db().transaction(|tx| {
let old_val = tx.get(&self.0.tree, &key)?;
let is_same = match (&old_val, &expected_old) {
(None, None) => true,
@@ -101,9 +101,9 @@ impl CountedTree {
tx.remove(&self.0.tree, &key)?;
}
}
- tx.commit(())
+ Ok(())
} else {
- tx.abort(())
+ Err(TxError::Abort(()))
}
});