aboutsummaryrefslogtreecommitdiff
path: root/syncapi/sync
diff options
context:
space:
mode:
authorNeil Alexander <neilalexander@users.noreply.github.com>2021-04-26 16:33:31 +0100
committerNeil Alexander <neilalexander@users.noreply.github.com>2021-04-26 16:33:42 +0100
commit464b908bd0c13854b3f6b9a17467f39e0608dc08 (patch)
tree7e30624189f84cabdb2960bb31bc79d028a44b83 /syncapi/sync
parentc67d8da3ebd011bca33f31e6ab12e173d8c87364 (diff)
Don't return immediately when there's nothing to sync
Diffstat (limited to 'syncapi/sync')
-rw-r--r--syncapi/sync/requestpool.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/syncapi/sync/requestpool.go b/syncapi/sync/requestpool.go
index 384fc25c..a4573610 100644
--- a/syncapi/sync/requestpool.go
+++ b/syncapi/sync/requestpool.go
@@ -156,7 +156,7 @@ func (rp *RequestPool) OnIncomingSyncRequest(req *http.Request, device *userapi.
currentPos := rp.Notifier.CurrentPosition()
- if !rp.shouldReturnImmediately(syncReq) {
+ if !rp.shouldReturnImmediately(syncReq, currentPos) {
timer := time.NewTimer(syncReq.Timeout) // case of timeout=0 is handled above
defer timer.Stop()
@@ -303,8 +303,8 @@ func (rp *RequestPool) OnIncomingKeyChangeRequest(req *http.Request, device *use
// shouldReturnImmediately returns whether the /sync request is an initial sync,
// or timeout=0, or full_state=true, in any of the cases the request should
// return immediately.
-func (rp *RequestPool) shouldReturnImmediately(syncReq *types.SyncRequest) bool {
- if syncReq.Since.IsEmpty() || syncReq.Timeout == 0 || syncReq.WantFullState {
+func (rp *RequestPool) shouldReturnImmediately(syncReq *types.SyncRequest, currentPos types.StreamingToken) bool {
+ if currentPos.IsAfter(syncReq.Since) || syncReq.Timeout == 0 || syncReq.WantFullState {
return true
}
return false