mirror of
https://github.com/tulir/mautrix-whatsapp
synced 2024-12-14 01:14:29 +01:00
backfill: fixed bug where the media backfill loop would sleep too often
If the number of requested message was a multiple of the number of batch events, then it would sleep on every single other message (even if not an errored media message).
This commit is contained in:
parent
d898aefff1
commit
76c6d0bf87
1 changed files with 4 additions and 3 deletions
|
@ -102,10 +102,11 @@ func (user *User) handleBackfillRequestsLoop(backfillRequests chan *database.Bac
|
|||
// requesting any media that errored.
|
||||
requested := 0
|
||||
for _, msg := range user.bridge.DB.Message.GetMessagesBetween(portal.Key, startTime, endTime) {
|
||||
if requested > 0 && requested%req.MaxBatchEvents == 0 {
|
||||
time.Sleep(time.Duration(req.BatchDelay) * time.Second)
|
||||
}
|
||||
if msg.Error == database.MsgErrMediaNotFound {
|
||||
if requested > 0 && requested%req.MaxBatchEvents == 0 {
|
||||
time.Sleep(time.Duration(req.BatchDelay) * time.Second)
|
||||
}
|
||||
|
||||
portal.requestMediaRetry(user, msg.MXID)
|
||||
requested += 1
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue