mozilla-services/android-sync — comment on commit 91987cdd058fcf3752869871022f712e19a0490b
File: src/main/java/org/mozilla/gecko/sync/repositories/android/ClientsDatabaseContentProvider.java line 47
By rnewman:

OK, so we're trading a DB write for a DB read followed by a possible DB write.

How about this: `db.update` with `WHERE guid = $newRecord.guid AND lastModified < $newRecord.modified`?

One call into the DB, won't make any changes unnecessarily.

wrt `shouldUpload`: as we just discussed, we never upload a client record for another client unless we're sending them a command (and my opinion is that we should use a `GET` followed by a `PUT` with `If-Unmodified-Since` to achieve that). We should only upload our own client record if the server-side record is missing or stale. Stale is defined as:

* modified time is older than some threshold (7 days, vs TTL of 21 days)
* someone sent us a command, and now we need to upload a cleared record.

If someone sent us a command, strictly speaking we should do another `If-Unmodified-Since` `PUT`, and if it fails process any new commands. But that's a topic for future discussion :)