ソースを参照

Fix panic in backfill if there are no messages to backfill

Tulir Asokan 3 年 前
コミット
f426b87dce
1 ファイル変更5 行追加3 行削除
  1. 5 3
      historysync.go

+ 5 - 3
historysync.go

@@ -117,8 +117,10 @@ func (user *User) handleHistorySync(evt *waProto.HistorySync) {
 func (user *User) slowBackfillLoop(ch chan portalToBackfill, done func()) {
 	defer done()
 	for ptb := range ch {
-		user.log.Debugln("Bridging history sync payload for", ptb.portal.Key.JID)
-		ptb.portal.backfill(user, ptb.msgs)
+		if len(ptb.msgs) > 0 {
+			user.log.Debugln("Bridging history sync payload for", ptb.portal.Key.JID)
+			ptb.portal.backfill(user, ptb.msgs)
+		}
 		if !ptb.conv.GetMarkedAsUnread() && ptb.conv.GetUnreadCount() == 0 {
 			user.markSelfReadFull(ptb.portal)
 		}
@@ -216,7 +218,7 @@ func (user *User) fastBackfillRoutine(ptb portalToBackfill, done func(), slowBac
 			// Send the rest of the messages off to the slow backfill queue
 			ptb.msgs = ptb.msgs[FastBackfillMessageCount:]
 			slowBackfillChan <- ptb
-		} else {
+		} else if len(ptb.msgs) > 0 {
 			user.log.Debugln("Bridging history sync payload for", ptb.portal.Key.JID, "(async)")
 			ptb.portal.backfill(user, ptb.msgs)
 		}