Pointerise types.RoomInfo in the cache so we can update it in-place in the latest events updater

This commit is contained in:
Neil Alexander 2022-07-13 10:13:34 +01:00
parent 9cd8e9d4b9
commit a1f9b02edf
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944
5 changed files with 15 additions and 16 deletions

View file

@ -139,13 +139,13 @@ func (d *Database) RoomInfo(ctx context.Context, roomID string) (*types.RoomInfo
}
func (d *Database) roomInfo(ctx context.Context, txn *sql.Tx, roomID string) (*types.RoomInfo, error) {
if roomInfo, ok := d.Cache.GetRoomInfo(roomID); ok {
return &roomInfo, nil
if roomInfo, ok := d.Cache.GetRoomInfo(roomID); ok && roomInfo != nil {
return roomInfo, nil
}
roomInfo, err := d.RoomsTable.SelectRoomInfo(ctx, txn, roomID)
if err == nil && roomInfo != nil {
d.Cache.StoreRoomServerRoomID(roomInfo.RoomNID, roomID)
d.Cache.StoreRoomInfo(roomID, *roomInfo)
d.Cache.StoreRoomInfo(roomID, roomInfo)
}
return roomInfo, err
}