Process devices before we sync (#779)

This commit is contained in:
Jesse Peterson
2021-10-01 15:07:51 -07:00
committed by GitHub
parent 6b63444b4a
commit 6dc4facba0

View File

@@ -3,6 +3,7 @@ package sync
import (
"context"
"encoding/json"
"fmt"
"strings"
"sync"
"time"
@@ -327,13 +328,13 @@ func (w *Watcher) Run() error {
"more", resp.MoreToFollow,
)
if err := w.publishAndProcessDevices(resp.Devices); err != nil {
return fmt.Errorf("publish and process devices: %w", err)
}
w.cursor = Cursor{Value: resp.Cursor, CreatedAt: time.Now()}
if err := w.db.SaveCursor(w.cursor); err != nil {
return errors.Wrap(err, "saving cursor from fetch")
}
if err := w.publishAndProcessDevices(resp.Devices); err != nil {
return err
}
if resp.MoreToFollow {
continue