mirror of
https://github.com/tulir/mautrix-whatsapp
synced 2024-06-10 15:08:58 +02:00
backfill queue: set the dispatch time instead of completed time
This commit is contained in:
parent
17c697445d
commit
c1bf0e6555
|
@ -51,7 +51,7 @@ func (bq *BackfillQueue) RunLoop(user *User) {
|
|||
} else {
|
||||
bq.log.Debugfln("Unrecognized backfill type %d in queue", backfill.BackfillType)
|
||||
}
|
||||
backfill.MarkDone()
|
||||
backfill.MarkDispatched()
|
||||
} else {
|
||||
select {
|
||||
case <-bq.ReCheckQueue:
|
||||
|
|
|
@ -167,9 +167,20 @@ func (b *Backfill) Insert() {
|
|||
}
|
||||
}
|
||||
|
||||
func (b *Backfill) MarkDispatched() {
|
||||
if b.QueueID == 0 {
|
||||
b.log.Errorf("Cannot mark backfill as dispatched without queue_id. Maybe it wasn't actually inserted in the database?")
|
||||
return
|
||||
}
|
||||
_, err := b.db.Exec("UPDATE backfill_queue SET dispatch_time=$1 WHERE queue_id=$2", time.Now(), b.QueueID)
|
||||
if err != nil {
|
||||
b.log.Warnfln("Failed to mark %s/%s as dispatched: %v", b.BackfillType, b.Priority, err)
|
||||
}
|
||||
}
|
||||
|
||||
func (b *Backfill) MarkDone() {
|
||||
if b.QueueID == 0 {
|
||||
b.log.Errorf("Cannot delete backfill without queue_id. Maybe it wasn't actually inserted in the database?")
|
||||
b.log.Errorf("Cannot mark backfill done without queue_id. Maybe it wasn't actually inserted in the database?")
|
||||
return
|
||||
}
|
||||
_, err := b.db.Exec("UPDATE backfill_queue SET completed_at=$1 WHERE queue_id=$2", time.Now(), b.QueueID)
|
||||
|
|
|
@ -136,6 +136,7 @@ func (user *User) handleBackfillRequestsLoop(backfillRequests chan *database.Bac
|
|||
conv := user.bridge.DB.HistorySync.GetConversation(user.MXID, req.Portal)
|
||||
if conv == nil {
|
||||
user.log.Debugfln("Could not find history sync conversation data for %s", req.Portal.String())
|
||||
req.MarkDone()
|
||||
continue
|
||||
}
|
||||
portal := user.GetPortalByJID(conv.PortalKey.JID)
|
||||
|
@ -157,6 +158,7 @@ func (user *User) handleBackfillRequestsLoop(backfillRequests chan *database.Bac
|
|||
}
|
||||
|
||||
user.backfillInChunks(req, conv, portal)
|
||||
req.MarkDone()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue