slightly simplify transact_inner()

This commit is contained in:
Damien Elmes 2021-05-28 14:45:36 +10:00
parent af50c445dd
commit e3db8641d1

View file

@ -14,21 +14,15 @@ impl Collection {
self.begin_undoable_operation(op); self.begin_undoable_operation(op);
func(self) func(self)
// any changes mean an mtime bump .and_then(|output| {
.and_then(|out| { // any changes mean an mtime bump
if !have_op || (self.current_undo_step_has_changes() && !self.undoing_or_redoing()) if !have_op || (self.current_undo_step_has_changes() && !self.undoing_or_redoing())
{ {
self.set_modified()?; self.set_modified()?;
} }
Ok(out) // then commit
})
// then commit
.and_then(|out| {
self.storage.commit_rust_trx()?; self.storage.commit_rust_trx()?;
Ok(out) // finalize undo
})
// finalize undo step
.map(|output| {
let changes = if have_op { let changes = if have_op {
let changes = self.op_changes(); let changes = self.op_changes();
self.maybe_clear_study_queues_after_op(&changes); self.maybe_clear_study_queues_after_op(&changes);
@ -43,7 +37,7 @@ impl Collection {
} }
}; };
self.end_undoable_operation(); self.end_undoable_operation();
OpOutput { output, changes } Ok(OpOutput { output, changes })
}) })
// roll back on error // roll back on error
.or_else(|err| { .or_else(|err| {