mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-02-14 23:14:27 -06:00
Don't panic on nil txns
This commit is contained in:
parent
f49f4e55e0
commit
436f07e79d
|
@ -40,6 +40,11 @@ type Transaction interface {
|
||||||
// You MUST check the error returned from this function to be sure that the transaction
|
// You MUST check the error returned from this function to be sure that the transaction
|
||||||
// was applied correctly. For example, 'database is locked' errors in sqlite will happen here.
|
// was applied correctly. For example, 'database is locked' errors in sqlite will happen here.
|
||||||
func EndTransaction(txn Transaction, succeeded *bool) error {
|
func EndTransaction(txn Transaction, succeeded *bool) error {
|
||||||
|
if txn == nil {
|
||||||
|
// Sometimes in SQLite mode we have nil transactions. If that's the case
|
||||||
|
// then we are working outside of a transaction and should do nothing here.
|
||||||
|
return nil
|
||||||
|
}
|
||||||
if *succeeded {
|
if *succeeded {
|
||||||
return txn.Commit()
|
return txn.Commit()
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue