From ae7919c2cf2c1b15714a3ec19af85710c012ad95 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Thu, 27 Jan 2022 15:10:30 +0000 Subject: [PATCH] Try to backfill via federation in error cases --- roomserver/internal/perform/perform_backfill.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/roomserver/internal/perform/perform_backfill.go b/roomserver/internal/perform/perform_backfill.go index f3623de8..21dd2fd9 100644 --- a/roomserver/internal/perform/perform_backfill.go +++ b/roomserver/internal/perform/perform_backfill.go @@ -79,21 +79,24 @@ func (r *Backfiller) PerformBackfill( // Scan the event tree for events to send back. resultNIDs, err := helpers.ScanEventTree(ctx, r.DB, info, front, visited, request.Limit, request.ServerName) if err != nil { - return err + return r.backfillViaFederation(ctx, request, response) } // Retrieve events from the list that was filled previously. var loadedEvents []*gomatrixserverlib.Event loadedEvents, err = helpers.LoadEvents(ctx, r.DB, resultNIDs) if err != nil { - return err + return r.backfillViaFederation(ctx, request, response) } for _, event := range loadedEvents { response.Events = append(response.Events, event.Headered(info.RoomVersion)) } - return err + if err != nil { + return r.backfillViaFederation(ctx, request, response) + } + return nil } func (r *Backfiller) backfillViaFederation(ctx context.Context, req *api.PerformBackfillRequest, res *api.PerformBackfillResponse) error {