From 7c63b5cbb480f05fdf9648ef4ff26669ae2fc004 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Wed, 27 May 2020 17:53:10 +0100 Subject: [PATCH] Handle nil in transaction --- roomserver/storage/shared/prepare.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/roomserver/storage/shared/prepare.go b/roomserver/storage/shared/prepare.go index e048d43af..65ceec1cc 100644 --- a/roomserver/storage/shared/prepare.go +++ b/roomserver/storage/shared/prepare.go @@ -43,10 +43,18 @@ type transaction struct { // Commit implements types.Transaction func (t *transaction) Commit() error { + if t.txn == nil { + // The Updater structs can operate in useTxns=false mode. The code will still call this though. + return nil + } return t.txn.Commit() } // Rollback implements types.Transaction func (t *transaction) Rollback() error { + if t.txn == nil { + // The Updater structs can operate in useTxns=false mode. The code will still call this though. + return nil + } return t.txn.Rollback() }