From ac1cbaf7198002f047598e015e4f69a246160e15 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Thu, 5 May 2022 13:39:41 +1000 Subject: [PATCH] Fix implicit transaction not being cleared on transact() failure "release foo" clears the implicit outer transaction, but "rollback to foo" does not. --- rslib/src/collection/transact.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/rslib/src/collection/transact.rs b/rslib/src/collection/transact.rs index 16c7575ed..19c253309 100644 --- a/rslib/src/collection/transact.rs +++ b/rslib/src/collection/transact.rs @@ -10,6 +10,7 @@ impl Collection { { let have_op = op.is_some(); let skip_undo_queue = op == Some(Op::SkipUndo); + let autocommit = self.storage.db.is_autocommit(); self.storage.begin_rust_trx()?; self.begin_undoable_operation(op); @@ -43,7 +44,11 @@ impl Collection { // roll back on error .or_else(|err| { self.discard_undo_and_study_queues(); - self.storage.rollback_rust_trx()?; + if autocommit { + self.storage.rollback_trx()?; + } else { + self.storage.rollback_rust_trx()?; + } Err(err) }) }