Fix some database transaction bugs

This commit is contained in:
Tulir Asokan 2023-01-04 02:13:20 +02:00
parent 16277a8702
commit 1ce4e4a219
3 changed files with 5 additions and 5 deletions

View file

@ -263,12 +263,12 @@ func (portal *Portal) Delete() {
portal.log.Warnfln("Failed to commit portal delete transaction: %v", err)
}
}()
_, err = portal.db.Exec("UPDATE portal SET in_space=false WHERE parent_group=$1", portal.Key.JID)
_, err = txn.Exec("UPDATE portal SET in_space=false WHERE parent_group=$1", portal.Key.JID)
if err != nil {
portal.log.Warnfln("Failed to mark child groups of %v as not in space: %v", portal.Key.JID, err)
return
}
_, err = portal.db.Exec("DELETE FROM portal WHERE jid=$1 AND receiver=$2", portal.Key.JID, portal.Key.Receiver)
_, err = txn.Exec("DELETE FROM portal WHERE jid=$1 AND receiver=$2", portal.Key.JID, portal.Key.Receiver)
if err != nil {
portal.log.Warnfln("Failed to delete %v: %v", portal.Key, err)
}

2
go.mod
View file

@ -11,7 +11,7 @@ require (
github.com/prometheus/client_golang v1.14.0
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e
github.com/tidwall/gjson v1.14.4
go.mau.fi/whatsmeow v0.0.0-20230101112920-9b93048f5e21
go.mau.fi/whatsmeow v0.0.0-20230104001256-9d98dc9b5702
golang.org/x/image v0.2.0
golang.org/x/net v0.4.0
google.golang.org/protobuf v1.28.1

4
go.sum
View file

@ -66,8 +66,8 @@ github.com/yuin/goldmark v1.5.3 h1:3HUJmBFbQW9fhQOzMgseU134xfi6hU+mjWywx5Ty+/M=
github.com/yuin/goldmark v1.5.3/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
go.mau.fi/libsignal v0.1.0 h1:vAKI/nJ5tMhdzke4cTK1fb0idJzz1JuEIpmjprueC+c=
go.mau.fi/libsignal v0.1.0/go.mod h1:R8ovrTezxtUNzCQE5PH30StOQWWeBskBsWE55vMfY9I=
go.mau.fi/whatsmeow v0.0.0-20230101112920-9b93048f5e21 h1:iDNhclPIMzMP2J3RW2d9qn+yjjV7TKt0WkcnRUiFonQ=
go.mau.fi/whatsmeow v0.0.0-20230101112920-9b93048f5e21/go.mod h1:TrdC8N6SnPFxWo5FiMnDIDFuVyfOLzy5dWDaUPNjcHY=
go.mau.fi/whatsmeow v0.0.0-20230104001256-9d98dc9b5702 h1:ZaDXqhk8KODLZCcWza0XLEXavJCZw68YKJ0Rttocrmg=
go.mau.fi/whatsmeow v0.0.0-20230104001256-9d98dc9b5702/go.mod h1:TrdC8N6SnPFxWo5FiMnDIDFuVyfOLzy5dWDaUPNjcHY=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.4.0 h1:UVQgzMY87xqpKNgb+kDsll2Igd33HszWHFLmpaRMq/8=