Native iCloud apps for Windows and Linux, built in Rust. Notes, Reminders, Calendar, Contacts, Drive and Photos, offline and in sync with your iPhone.
Rust apple-notesapple-reminderscloudkitcrdtdesktop-appicloudicloud-calendaricloud-driveicloud-notesicloud-photosiphonelinuxlinux-desktoplocal-firstoffline-firstprivacyrusttauritauri-appwindows
Sync: a full pass stamped in the future is due now
Yashwanth Kamireddi8b9b50ddc2b1
diff --git a/crates/quince-core/src/health.rs b/crates/quince-core/src/health.rsindex 720bb7c..2840dfc 100644--- a/crates/quince-core/src/health.rs+++ b/crates/quince-core/src/health.rs@@ -54,7 +54,10 @@ impl Library {////// A delta cannot remove a record whose tombstone it never saw, so a full pass runs/// occasionally to reconcile against the whole truth. Never having done one counts as- /// due, which is what heals a library that predates this bookkeeping.+ /// due, which is what heals a library that predates this bookkeeping. So does one stamped+ /// later than now: made while the clock ran ahead (a dead RTC battery, a wrong time zone+ /// on dual boot), it said "not due" until the clock caught up — for years, at worst, with+ /// every record deleted elsewhere whose tombstone a delta missed still shown here.pub fn needs_full_sync(&self, service: &str, every_seconds: i64) -> Result<bool> {let last: Option<i64> = self.conn@@ -65,9 +68,10 @@ impl Library {).ok().flatten();+ let now = now();Ok(match last {None => true,- Some(at) => now().saturating_sub(at) >= every_seconds,+ Some(at) => at > now || now.saturating_sub(at) >= every_seconds,})}@@ -123,6 +127,22 @@ mod tests {Library::in_memory().unwrap()}+ /// A full pass stamped in the future — the clock ran ahead when it was made, and was put+ /// right since — is due now, not once the clock catches up with it.+ #[test]+ fn a_full_pass_stamped_in_the_future_is_due() {+ let lib = library();+ lib.mark_full_sync("drive").unwrap();+ assert!(!lib.needs_full_sync("drive", 3600).unwrap(), "just done");+ lib.conn+ .execute(+ "UPDATE sync_state SET last_full_at = ?1 WHERE service = 'drive'",+ params![now() + 3 * 365 * 86_400],+ )+ .unwrap();+ assert!(lib.needs_full_sync("drive", 3600).unwrap());+ }+#[test]fn a_failure_is_recorded_without_claiming_freshness() {let lib = library();