diff --git a/roomserver/internal/perform/perform_admin.go b/roomserver/internal/perform/perform_admin.go index 19f2493c9..7bbfac0dd 100644 --- a/roomserver/internal/perform/perform_admin.go +++ b/roomserver/internal/perform/perform_admin.go @@ -246,10 +246,14 @@ func (r *Admin) PerformAdminPurgeRoom( return nil } - logrus.WithField("room_id", req.RoomID).Warn("Purging room from roomserver") - defer logrus.WithField("room_id", req.RoomID).Warn("Room purged from roomserver") - - if err := r.DB.PurgeRoom(ctx, req.RoomID); err != nil { + if err := r.Inputer.OutputProducer.ProduceRoomEvents(req.RoomID, []api.OutputEvent{ + { + Type: api.OutputTypePurgeRoom, + PurgeRoom: &api.OutputPurgeRoom{ + RoomID: req.RoomID, + }, + }, + }); err != nil { res.Error = &api.PerformError{ Code: api.PerformErrorBadRequest, Msg: err.Error(), @@ -257,12 +261,16 @@ func (r *Admin) PerformAdminPurgeRoom( return nil } - return r.Inputer.OutputProducer.ProduceRoomEvents(req.RoomID, []api.OutputEvent{ - { - Type: api.OutputTypePurgeRoom, - PurgeRoom: &api.OutputPurgeRoom{ - RoomID: req.RoomID, - }, - }, - }) + logrus.WithField("room_id", req.RoomID).Warn("Purging room from roomserver") + if err := r.DB.PurgeRoom(ctx, req.RoomID); err != nil { + logrus.WithField("room_id", req.RoomID).WithError(err).Warn("Failed to purge room from roomserver") + res.Error = &api.PerformError{ + Code: api.PerformErrorBadRequest, + Msg: err.Error(), + } + } else { + logrus.WithField("room_id", req.RoomID).Warn("Room purged from roomserver") + } + + return nil } diff --git a/roomserver/storage/shared/storage.go b/roomserver/storage/shared/storage.go index 883cc9e87..641633b4e 100644 --- a/roomserver/storage/shared/storage.go +++ b/roomserver/storage/shared/storage.go @@ -1361,11 +1361,7 @@ func (d *Database) PurgeRoom(ctx context.Context, roomID string) error { } return d.Writer.Do(d.DB, nil, func(txn *sql.Tx) error { roomNID, err := d.RoomsTable.SelectRoomNID(ctx, txn, roomID) - switch err { - case sql.ErrNoRows: - return nil // return nil anyway so we can generate output event for other components - case nil: - default: + if err != nil { return fmt.Errorf("failed to find room NID: %w", err) } if err := d.Purge.PurgeStateBlocks(ctx, txn, roomNID); err != nil {