Explorar o código

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).
Sumner Evans %!s(int64=3) %!d(string=hai) anos
pai
achega
76c6d0bf87
Modificáronse 1 ficheiros con 4 adicións e 3 borrados
  1. 4 3
      historysync.go

+ 4 - 3
historysync.go

@@ -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
 				}