Hey Graham, I noticed I was having to handle sync conflicts every time I sycn'd on my XTEink4, so I went digging! I'm very unfamiliar with Rust, so I'll do my best to explain what I saw here, in the hope that any blunders I've made are easier to spot!
It looks like Headway currently replaces the pageturn timestamp KOReader sends on syncwith its own timestamp ('now', when the request arrives).
Often this is just a few milliseconds later, but if it's later at all the next sync will see a conflict with the time it remembers the previous sync was at — forcing the unnecessary dialog.
My changes:
-
Store the device-provided timestamp on the server, so the device can correctly dismiss it as the same it previously saw
-
An older-timestamped write can no longer overwrite a newer position (eg. if the write was delayed) — it's skipped, and the newer position survives to trigger the device's own conflict prompt on its next pull
-
Store the device's last page turn timestamp on the PDS too, rather than the moment of sync. This makes cross-device sync less likely to cause prompts (you're almost certainly not turning the page on two devices at once!)
-
Replace page turn timestamps more than a minute in the future with 'now' of the server clock (KOReader NTP-syncs before submitting, so this should be more than enough), so that there's no issue with an implausibly far-future page turn messing up future syncs
I hope this helps! 😊