backfill: fix stopTakeoutTimer

Signed-off-by: Sumner Evans <sumner.evans@automattic.com>
This commit is contained in:
Sumner Evans
2024-09-26 10:01:05 -06:00
parent ce1c28832e
commit 7af4ecc719
+7 -1
View File
@@ -162,7 +162,13 @@ func (t *TelegramClient) FetchMessages(ctx context.Context, fetchParams bridgev2
return nil, err
}
defer t.stopTakeoutTimer.Reset(max(time.Hour, time.Duration(t.main.Bridge.Config.Backfill.Queue.BatchDelay*2)))
defer func() {
if t.stopTakeoutTimer == nil {
t.stopTakeoutTimer = time.AfterFunc(max(time.Hour, time.Duration(t.main.Bridge.Config.Backfill.Queue.BatchDelay*2)), sync.OnceFunc(func() { t.stopTakeout(ctx) }))
} else {
t.stopTakeoutTimer.Reset(max(time.Hour, time.Duration(t.main.Bridge.Config.Backfill.Queue.BatchDelay*2)))
}
}()
}
peer, err := t.inputPeerForPortalID(ctx, fetchParams.Portal.ID)