Let the roomserver work first

This commit is contained in:
Neil Alexander 2022-08-25 12:11:00 +01:00
parent c1d6e18152
commit b7258dcc00
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944
2 changed files with 11 additions and 16 deletions

View file

@ -246,21 +246,6 @@ func (r *Admin) PerformAdminPurgeRoom(
return nil 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") logrus.WithField("room_id", req.RoomID).Warn("Purging room from roomserver")
if err := r.DB.PurgeRoom(ctx, req.RoomID); err != nil { 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") 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") 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,
},
},
})
} }

View file

@ -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 { return d.Writer.Do(d.DB, nil, func(txn *sql.Tx) error {
roomNID, err := d.RoomsTable.SelectRoomNIDForUpdate(ctx, txn, roomID) roomNID, err := d.RoomsTable.SelectRoomNIDForUpdate(ctx, txn, roomID)
if err != nil { if err != nil {
if err == sql.ErrNoRows {
return nil
}
return fmt.Errorf("failed to lock the room: %w", err) return fmt.Errorf("failed to lock the room: %w", err)
} }
if err := d.Purge.PurgeStateBlocks(ctx, txn, roomNID); err != nil { if err := d.Purge.PurgeStateBlocks(ctx, txn, roomNID); err != nil {