Synchronization

About the actual synchronization process

Sync algorithm: PROPFIND/REPORT

  1. Unset "present remotely" flag for all resources
  2. List remote resources (only names and ETags) using PROPFIND or REPORT (see above)
  3. Compare local and remote resources: determine which resources have been
    • added remotely → will be downloaded and created locally
    • updated remotely → will be downloaded and updated locally
    • set "present remotely" flag for all received resources
  4. Process remote changes: download remote resources
    • in bunches of max. 10 contacts at once using GET (for single contacts) or REPORT addressbook-multiget or
    • in bunches of max. 20 events/tasks at once using GET (for single resources) or REPORT calendar-multiget and
    • insert them into the respective local storage
  5. Locally delete all resources which are not flagged as "present remotely"
  6. Post-processing: clean up empty contact groups etc.
  7. Save sync state (CTag/sync-token)

Conflict handling

Conflicts occur when different versions of a resource are available and it's ambigous which one shall be used. For instance:

  1. A contact exists on the server and has been synchronized to a mobile phone with DAVdroid and to a desktop PC with Gnome Evolution.
  2. You modify the contact with Evolution, which immediately uploads it to the server.
  3. You modify the same contact on your mobile device, too.
  4. DAVdroid wants to upload the modified contact and finds that it has been changed on the server in the meanwhile. Now there's a conflict of two different versions of this contact.

How DAVdroid handles such conflicts:

  • DAVdroid relies on HTTP ETags to determine whether a resource has been changed on the server.
  • The server always wins. If a local resource can't be uploaded or deleted safely because it has been modified on the server in the meanwhile, local changes are discarded and the server version is used.
  • DAVdroid doesn't involve the user in resolving conflicts (like asking which version shall be used) because it's supposed to run in the background silently.

Last updated: 15 Aug 2018