From 8e2eeb76a9600dc7446ccd9ebe2f6794a4d4d92b Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Mon, 10 Oct 2022 14:43:55 +0100 Subject: [PATCH] Another joined hosts fix --- federationapi/storage/shared/storage.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/federationapi/storage/shared/storage.go b/federationapi/storage/shared/storage.go index 1035df69c..d174f0074 100644 --- a/federationapi/storage/shared/storage.go +++ b/federationapi/storage/shared/storage.go @@ -69,6 +69,7 @@ func (d *Database) UpdateRoom( purgeRoomFirst bool, ) (joinedHosts []types.JoinedHost, err error) { err = d.Writer.Do(d.DB, nil, func(txn *sql.Tx) error { + var joinedHosts []types.JoinedHost if purgeRoomFirst { // If the event is a create event then we'll delete all of the existing // data for the room. The only reason that a create event would be replayed @@ -76,11 +77,10 @@ func (d *Database) UpdateRoom( if err = d.FederationJoinedHosts.DeleteJoinedHostsForRoom(ctx, txn, roomID); err != nil { return fmt.Errorf("d.FederationJoinedHosts.DeleteJoinedHosts: %w", err) } - } - - joinedHosts, err = d.FederationJoinedHosts.SelectJoinedHostsWithTx(ctx, txn, roomID) - if err != nil { - return err + } else { + if joinedHosts, err = d.FederationJoinedHosts.SelectJoinedHostsWithTx(ctx, txn, roomID); err != nil { + return err + } } for _, add := range addHosts {