diff --git a/roomserver/internal/perform/perform_admin.go b/roomserver/internal/perform/perform_admin.go index 7bbfac0dd..bf2157aaf 100644 --- a/roomserver/internal/perform/perform_admin.go +++ b/roomserver/internal/perform/perform_admin.go @@ -246,21 +246,6 @@ func (r *Admin) PerformAdminPurgeRoom( return 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(), - } - return nil - } - 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") @@ -272,5 +257,12 @@ func (r *Admin) PerformAdminPurgeRoom( logrus.WithField("room_id", req.RoomID).Warn("Room purged from roomserver") } - return nil + return r.Inputer.OutputProducer.ProduceRoomEvents(req.RoomID, []api.OutputEvent{ + { + Type: api.OutputTypePurgeRoom, + PurgeRoom: &api.OutputPurgeRoom{ + RoomID: req.RoomID, + }, + }, + }) } diff --git a/roomserver/storage/shared/storage.go b/roomserver/storage/shared/storage.go index fca767662..add90508a 100644 --- a/roomserver/storage/shared/storage.go +++ b/roomserver/storage/shared/storage.go @@ -1362,6 +1362,9 @@ 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.SelectRoomNIDForUpdate(ctx, txn, roomID) if err != nil { + if err == sql.ErrNoRows { + return nil + } return fmt.Errorf("failed to lock the room: %w", err) } if err := d.Purge.PurgeStateBlocks(ctx, txn, roomNID); err != nil {