KOSync: queue failed progress updates for retry on reconnect (#15324)

When the sync server is unreachable (offline reading, intermittent WiFi,
server down), progress updates are now queued locally instead of being
silently dropped. Queued items are drained on the next successful network
connection.

Queue behavior:
- One entry per document per day (preserves daily reading statistics)
- Entries expire after 4 weeks
- Hard cap of 200 entries as safety net
- Auth failures (401) are not queued (won't resolve by retrying)
- Queue is cleared on logout

Integration points:
- updateProgress: queues on pcall failure or non-auth callback failure
- _onNetworkConnected: drains queue before pulling remote progress
- _onCloseDocument: queues immediately if offline instead of blocking
  with goOnlineToRun (avoids WiFi prompts on document close)

Fixes #9267, fixes #10678, fixes #11105
This commit is contained in:
collaed authored and GitHub committed 2026-07-08 19:27:10 +02:00
1 parent 72d4c924a1
commit 009367df7a
4 files changed
+342 -15

No files matched your search

+2 -2
View File
@@ -134,10 +134,10 @@ function KOSyncClient:update_progress(
})
end)
if ok then
callback(res.status == 200, res.body)
callback(res.status == 200, res.status, res.body)
else
logger.dbg("KOSyncClient:update_progress failure:", res)
callback(false, res.body)
callback(false, nil, nil)
end
end)
self.client:enable("AsyncHTTP", {thread = co})