[OwnCloud] Losing contacts after sync with DAVdroid 0.8.1+



  • Both 0.8.1 and 0.8.0 versions affected. I sync to ownCloud server (v8.1, yesterday upgraded from v8.0) installed on my computer. OwnCloud correctly displays 469 contacts, DAVdroid synchronizes them all (I monitor number of contacts during synchronization), but as soon as it finishes, number of contacts comes down to 37. I tried several times, contacts are always the same. I even uninstalled Viber and WhatsApp, thinking they could mess with contacts. One thing that I noticed, is that vCard version (DAVdroid settings) is 4.0, I'm not sure what was it before upgrade to 0.8.1. On my 4.4.4 rom the vCard version was always 3.0.

    Currently I'm running Lollipop (Euphoria OS). Logcat extracted, I can upload if required.


  • admin

    seems that this could be a new issue with owncloud 8.1. if you downgrade to your previous version of oc does it work?



  • Reverting to ownCloud 8.0 would be too complicated, as I need to remove everything, install previous version and start over. I'll try to figure out the difference between raw vcard file of contacts which remained in DAVdroid and those which didn't.



  • Okay, It was smoother than I thought. :) I reverted ownCloud back to v8.0, started from clean, also started from a clean profile in DAVdroid. This time in options there is vCard v3.0. Appart from that I had to start synchronization twice (first time only ~350 out 470 contacts was synchronized), everything works. Just left to see whether it will survive moving DAVdroid to /system and reboot.


  • admin

    alright, thanks for the update! yes, I thought of a problem with owncloud because with testing internally we had problems too and the owncloud releases have been always a bit unstable recently (at least with their caldav/carddav part) :]

    hopefully they'll fix it soon!



  • I have made a bug report upstream: https://github.com/owncloud/contacts/issues/979.



  • I have the same problem with OC 8.1 and DAVdroid 0.8.1 since upgrading owncloud. I have tried various times with various options (and also with different devices).
    If I sync my contacts with "CardDAV-Sync free" from the play store every contact gets transferred (just without the groups). So maybe DAVdroid needs some changes too?


  • developer

    Maybe this is related to the cookie support introduced with DAVdroid/0.8.1?

    Unfortunately, I couldn't test with OwnCloud/8.1 because after the upgrade from 8.0, the OwnCloud Contact/Calendar apps were removed and I can't install them anymore.



  • I have also seen a lot of Sync Issues in the notification drawer. I had not yet connected this to the OC 8.1 update, but now it looks like this is the reason. I'm to lazy to downgrade and upgrade again.

    I achieved the cleanest sync by deleting both databases (phone + oc) and then imported the multi-vcf exported from OC on the phone into the newly created empty Davdroid account.

    Took some time until the contacts were uploaded, but then it was at least almost okay. (some addresses seem to have been messed...).

    Will try to reduce my contact editing until either side fixes this...



  • After some debugging I suspect the bug lies within this line in method deleteAllExceptRemoteNames in class LocalCollection:319:
    sqlFileNames.add(DatabaseUtils.sqlEscapeString(res.getName()));
    When I checked my contact database on my device before deleteAllExceptRemoteNames gets executed, all my owncloud contacts were present and their source ids contained '@foo.bar.de.vcf'. However the sqlEscapeString method escapes the @ to %40, so (almost) no contacts matches the sql query anymore and get deleted. I replaced the line with sqlFileNames.add(DatabaseUtils.sqlEscapeString(res.getName()).replace("%40", "@"));, and my contacts seemed to stay on my device.



  • Hi, I get the same issue with both 0.8.0 and 0.8.1 to ownCloud 8.1.

    I did notice that the old ownCloud contacts didnt have the vcard 4.0 option ticked.

    nginx/1.8.0
    PHP 5.4.41-0+deb7u1 (fpm-fcgi) with XCache v2.0.0
    ownCloud 8.1.0 with 'memcache.local' => '\OC\Memcache\XCache'
    DavDroid/0.8.1 (0.8.0 also) on HTC M8 android 5.0.1



  • However the sqlEscapeString method escapes the @ to %40, so (almost) no contacts matches the sql query anymore and get deleted. I replaced the line with sqlFileNames.add(DatabaseUtils.sqlEscapeString(res.getName()).replace("%40", "@"));, and my contacts seemed to stay on my device.

    Then this is DAVdroid bug, after all.



  • In my case the the sync of several addressbooks from Owncloud 8.1 with DavDroid 0.8.1 works fine, but the calendar sync doesn't work. The account setup works and it says "synced" but nothing is displayed.



  • However the sqlEscapeString method escapes the @ to %40, so (almost) no contacts matches the sql query anymore and get deleted. I replaced the line with sqlFileNames.add(DatabaseUtils.sqlEscapeString(res.getName()).replace("%40", "@"));, and my contacts seemed to stay on my device.

    I would be happy to test your change if you can supply a precompiled apk
    I can reproduce the issue on both of my phones



  • I would be available for testing as well. Just upload a apk somewhere and give me the link.



  • Here is the link to my test build: davdroid-debug.apk
    Please note that this is just a test build from me related to this issue and should not be used for daily usage. I do not take any responsibility for any harm caused by using this apk.

    This is the git diff from the code I used:

    diff --git a/app/src/main/java/at/bitfire/davdroid/resource/LocalAddressBook.java b/app/src/main/java/at/bitfire/davdroid/resource/LocalAddressBook.java
    index 65e2891..3479ac9 100644
    --- a/app/src/main/java/at/bitfire/davdroid/resource/LocalAddressBook.java
    +++ b/app/src/main/java/at/bitfire/davdroid/resource/LocalAddressBook.java
    @@ -139,7 +139,7 @@ public class LocalAddressBook extends LocalCollection<Contact> {
                    if (remoteResources.length != 0) {
                            List<String> sqlFileNames = new LinkedList<>();
                            for (Resource res : remoteResources)
    -                               sqlFileNames.add(DatabaseUtils.sqlEscapeString(res.getName()));
    +                               sqlFileNames.add(DatabaseUtils.sqlEscapeString(res.getName()).replace("%40", "@"));
                            where = entryColumnRemoteName() + " NOT IN (" + StringUtils.join(sqlFileNames, ",") + ")";
                    } else
                            where = entryColumnRemoteName() + " IS NOT NULL";
    

  • developer

    However the sqlEscapeString method escapes the @ to %40, so (almost) no contacts matches the sql query anymore and get deleted. I replaced the line with sqlFileNames.add(DatabaseUtils.sqlEscapeString(res.getName()).replace("%40", "@"));, and my contacts seemed to stay on my device.

    I can't reproduce that.

    Log.i(TAG, "SQLite escaped: " + DatabaseUtils.sqlEscapeString("a@b.com"));
    

    gives a@b.com here.

    However the sqlEscapeString method escapes the @ to %40

    Can you back this up? I don't think @ should be escaped in SQL strings, and sqlEscapeString doesn't behave like that here.


  • developer

    When trying to reproduce this bug, I ran into https://github.com/owncloud/contacts/issues/808. Is sharing enabled in your installation? If not, can you try to enable it?

    Can you please

    1. delete or rename your OwnCloud log (data/owncloud.log)
    2. do a DAVdroid sync
    3. access Contacts module in the Web Interface
    4. post the contents of your owncloud.log


  • I can confirm that mherzberg's apk fixes this for me. Thank you!

    Previously, I was getting error messages in the notification menu every hour or so. Unfortunately, I forget what they said precisely.

    I attempted uninstalling DAVdroid, then installing version 0.7.7. My phone would only import three contacts (out of 150). Oddly enough, I think these were the only contacts that I had added via the phone/DAVdroid. The others had been added/imported via OwnCloud's web interface a while ago.

    I also attempted installing DAVdroid 0.8.0 and 0.8.1. Neither fixed this issue. Only when installing mherzberg fix did it work. Thanks again!



  • Ahhh… after a while I've noticed mherzberg's apk is buggy too. Every time DAVdroid syncs, it creates an additional copy of each contact, except the three contacts that were the only ones synced in the official versions of DAVdroid (as per my previous post). Hence, after three syncs, I have one copy of these original three in my Android address book as expected, but three copies of every other contact!


Log in to reply
 

Looks like your connection to Bitfire App Forums was lost, please wait while we try to reconnect.