<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style id="owaParaStyle" type="text/css">P {margin-top:0;margin-bottom:0;}</style>
</head>
<body ocsi="0" fpstyle="1">
<div style="direction: ltr;font-family: Tahoma;color: #000000;font-size: 10pt;">Hi Eli,<br>
<br>
Probably the best way would be to look at the RemoveContactDetails trigger:<br>
<a href="https://git.merproject.org/mer-core/qtcontacts-sqlite/blob/master/src/engine/contactsdatabase.cpp#L353" target="_blank">https://git.merproject.org/mer-core/qtcontacts-sqlite/blob/master/src/engine/contactsdatabase.cpp#L353</a><br>
<br>
If you can determine which contactId entries are from carddav sync target contacts, then you can use the remove trigger logic to remove all of the associated carddav data.<br>
<br>
(The out-of-band (OOB) table is slightly different but inspection should make it obvious which OOB entry relates to the carddav account.)<br>
<br>
Best regards,<br>
Chris.<br>
<br>
<div style="font-family: Times New Roman; color: #000000; font-size: 16px">
<hr tabindex="-1">
<div style="direction: ltr;" id="divRpF348311"><font color="#000000" face="Tahoma" size="2"><b>From:</b> Devel [devel-bounces@lists.sailfishos.org] on behalf of E.S. Rosenberg [es.rosenberg+sailfishos.org@gmail.com]<br>
<b>Sent:</b> Friday, March 03, 2017 6:23 AM<br>
<b>To:</b> Sailfish OS Developers<br>
<b>Subject:</b> Re: [SailfishDevel] [CardDAV] duplicate entries<br>
</font><br>
</div>
<div></div>
<div>
<div dir="ltr">
<div class="gmail_extra">
<div class="gmail_quote">2017-02-20 20:32 GMT+02:00 E.S. Rosenberg <span dir="ltr">
<<a href="redir.aspx?REF=XPhgpaUhCVaazPDQGUtehHBlZzwBIOOJPiVMDqGtQNjbfSSE-2HUCAFtYWlsdG86ZXMucm9zZW5iZXJnK3NhaWxmaXNob3Mub3JnQGdtYWlsLmNvbQ.." target="_blank">es.rosenberg+sailfishos.org@gmail.com</a>></span>:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
<div dir="ltr"><br>
<div class="gmail_extra"><br>
<div class="gmail_quote"><span class="">2017-02-20 12:54 GMT+02:00 E.S. Rosenberg
<span dir="ltr"><<a href="redir.aspx?REF=XPhgpaUhCVaazPDQGUtehHBlZzwBIOOJPiVMDqGtQNjbfSSE-2HUCAFtYWlsdG86ZXMucm9zZW5iZXJnK3NhaWxmaXNob3Mub3JnQGdtYWlsLmNvbQ.." target="_blank">es.rosenberg+sailfishos.org@<wbr>gmail.com</a>></span>:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
<div dir="ltr">
<div class="gmail_extra">
<div class="gmail_quote"><span>2017-02-20 12:32 GMT+02:00 E.S. Rosenberg <span dir="ltr">
<<a href="redir.aspx?REF=jWSfF8O4FhwExLwGbDMYv5SzUlADplYkA7XvkuIIexw_3yaE-2HUCAFtYWlsdG86ZXMucm9zZW5iZXJnK3NhaWxmaXNob3Mub3JnQGdtYWlsLmNvbQ.." target="_blank">es.rosenberg+sailfishos.org@g<wbr>mail.com</a>></span>:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
<div dir="ltr">
<div>
<div class="gmail_extra">
<div class="gmail_quote">2017-02-20 3:41 GMT+02:00 Chris Adams <span dir="ltr"><<a href="redir.aspx?REF=iQpAk9G-1pOPPFH3h0hNAyFMRju0eKBXuH8zOfzydXA_3yaE-2HUCAFtYWlsdG86Y2hyaXMuYWRhbXNAam9sbGEuY29t" target="_blank">chris.adams@jolla.com</a>></span>:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex; border-left:1px solid rgb(204,204,204); padding-left:1ex">
<div>
<div style="direction:ltr; font-family:tahoma; color:rgb(0,0,0); font-size:10pt">
Hi Eli,<br>
</div>
</div>
</blockquote>
<div>Hi Chris, <br>
</div>
<span>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex; border-left:1px solid rgb(204,204,204); padding-left:1ex">
<div>
<div style="direction:ltr; font-family:tahoma; color:rgb(0,0,0); font-size:10pt">
<br>
Sorry for top posting, but OWA doesn't quote properly.<br>
</div>
</div>
</blockquote>
</span>
<div>No problem.... <br>
</div>
<span>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex; border-left:1px solid rgb(204,204,204); padding-left:1ex">
<div>
<div style="direction:ltr; font-family:tahoma; color:rgb(0,0,0); font-size:10pt">
<br>
Firstly, was_local contacts occur when a local (phone device) contact is aggregated into another contact which already had a local constituent.  We only allow one single local constituent per aggregate contact, so one of them gets demoted to was_local.  This
 can occur if you import from a .vcf or via Bluetooth, for example.<br>
</div>
</div>
</blockquote>
</span>
<div>Is there somewhere I can read more on this subject? <br>
</div>
<span>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex; border-left:1px solid rgb(204,204,204); padding-left:1ex">
<div>
<div style="direction:ltr; font-family:tahoma; color:rgb(0,0,0); font-size:10pt">
<br>
If you can reproduce the duplication event and provide sync logs of that event (as per
<a href="redir.aspx?REF=8QESkmYLDQIdVmp7XEcsPk_yUL_ew6HkmCoK-DHYPoQ_3yaE-2HUCAFodHRwczovL3NhaWxmaXNob3Mub3JnL3dpa2kvQ2FsREFWX2FuZF9DYXJkREFWX0NvbW11bml0eV9Db250cmlidXRpb25zI1N5bmNfTG9ncw.." target="_blank">
https://sailfishos.org/wiki/Ca<wbr>lDAV_and_CardDAV_Community_Con<wbr>tributions#Sync_Logs</a>) that would be helpful!<br>
</div>
</div>
</blockquote>
</span>
<div>I'll try. <br>
</div>
<span>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex; border-left:1px solid rgb(204,204,204); padding-left:1ex">
<div>
<div style="direction:ltr; font-family:tahoma; color:rgb(0,0,0); font-size:10pt">
<br>
You should be able to delete the contacts from the database so long as you also delete any entries from the OOB table which relate to that CardDAV account.<br>
</div>
</div>
</blockquote>
</span>
<div>So I actually deleted very aggressively yesterday (all carddav and all google) but did not modify oob, which resulted in 0 contacts being read, however even restoring the backed up contacts.db file does not fix this issue.<br>
</div>
<div>Any pointers what may be going wrong or where to look would be very welcome.<br>
</div>
<div>Thanks,<br>
</div>
<div>Eli<br>
</div>
</div>
</div>
</div>
</div>
</blockquote>
<div><br>
</div>
</span>
<div>Tiny additional update:<br>
</div>
<div>From digging through contacts.db it seems that it needs a lot more cleanup then just the contacts table, tables with crazy counts:<br>
</div>
<div>addresses, birthdays, avatars, deletedcontacts (~4k entries), details (>100k), emailaddresses, guids (~25k), organizations (~16k), phonenumbers (~56k), relationships (~25k), urls.<br>
<br>
</div>
<div>
<div class="m_877308848816044609h5">
<div>Thanks,<br>
</div>
<div>Eli<br>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</span>
<div>It seems I made a mistake when restoring the backup I now again have all my contacts :)<br>
<br>
</div>
<div>Now my first step I think is going to be to cleanly remove all carddav sync data, any pointers on that will be much appreciated (I assume I need to somehow cascade the delete into all the linked tables), when that is done I'll turn carddav back on and
 see if I can again trigger such a sync situation with logs.<br>
<br>
</div>
<div>
<div class="h5">
<div>Thanks,<br>
</div>
<div>Eli</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
<div><br>
</div>
<div>Hi Chris,<br>
</div>
<div>Is there any chance you can provide a schematic overview of the contacts.db file of the different relations etc.?<br>
</div>
<div>I really want to clean up but reverse engineering from column names is sub-ideal.<br>
</div>
<div>Thanks,<br>
</div>
<div>Eli<br>
</div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
<div dir="ltr">
<div class="gmail_extra">
<div class="gmail_quote">
<div>
<div class="h5">
<div><br>
</div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
<div dir="ltr">
<div class="gmail_extra">
<div class="gmail_quote">
<div>
<div class="m_877308848816044609h5">
<div></div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
<div dir="ltr">
<div>
<div class="gmail_extra">
<div class="gmail_quote">
<div></div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex; border-left:1px solid rgb(204,204,204); padding-left:1ex">
<div>
<div class="m_877308848816044609m_2060332310301111148h5">
<div>
<div style="direction:ltr; font-family:tahoma; color:rgb(0,0,0); font-size:10pt">
<br>
Best regards,<br>
Chris.<br>
<br>
<br>
<div style="font-family:times new roman; color:rgb(0,0,0); font-size:16px">
<hr>
<div id="m_877308848816044609m_2060332310301111148m_5099487734385163619gmail-m_6567888931506936618divRpF14514" style="direction:ltr">
<font color="#000000" face="Tahoma" size="2"><b>From:</b> Devel [<a href="redir.aspx?REF=Ox-nx0ff5GgT_5qNkKWidas423U1IL-s8sJUKbwuYp8_3yaE-2HUCAFtYWlsdG86ZGV2ZWwtYm91bmNlc0BsaXN0cy5zYWlsZmlzaG9zLm9yZw.." target="_blank">devel-bounces@lists.sailfisho<wbr>s.org</a>]
 on behalf of E.S. Rosenberg [<a href="redir.aspx?REF=bdmY5T2XOIki5RYjd7Qnnl_KiUFoeUTysvJ-7WRhmBU_3yaE-2HUCAFtYWlsdG86ZXMucm9zZW5iZXJnJTJCc2FpbGZpc2hvcy5vcmdAZ21haWwuY29t" target="_blank">es.rosenberg+sailfishos.org@g<wbr>mail.com</a>]<br>
<b>Sent:</b> Monday, February 20, 2017 9:13 AM<br>
<b>To:</b> Sailfish OS Developers<br>
<b>Subject:</b> [SailfishDevel] [CardDAV] duplicate entries<br>
</font><br>
</div>
<div>
<div class="m_877308848816044609m_2060332310301111148m_5099487734385163619gmail-h5">
<div></div>
<div>
<div dir="ltr">
<div>
<div>
<div>
<div>
<div>
<div>
<div>Hi everyone,<br>
</div>
Last week I noticed that my phone seems to have gone into similar behavior as I described a long time ago with google sync here:<br>
<a href="redir.aspx?REF=LwLZZ5noVQTKqMsF22dOPQq00HLUARDzfA1-J5n1jnA_3yaE-2HUCAFodHRwOi8vcmVkaXIuYXNweD9SRUY9QmtpblU2cHg5RnJNNTRkNmllbENlRFhDRDVESWlaZlZiY2J6ck0xdXpCSnM0VmlPTUZuVUNBRm9kSFJ3Y3pvdkwzUnZaMlYwYUdWeUxtcHZiR3hoTG1OdmJTOXhkV1Z6ZEdsdmJpODFPRFF4Tmk5bWFYaHBibWN0ZEdobExXTnZiblJoWTNSekxXUmlMdy4u" target="_blank">https://together.jolla.com/que<wbr>stion/58416/fixing-the-contact<wbr>s-db/</a><br>
<br>
</div>
I currenlty have 26k entries in contacts.db for 9xx contacts.<br>
<br>
</div>
I suspect that this may be linked to a stage where I was connected via a filtered provider that tried to MITM the connection and caused it to close with an authentication error, I'm going to clean it up the same way I described there and turn carddav back on
 but I am wondering if anyone else has experienced similar issues.<br>
<br>
</div>
<div>Is anyone aware of any reason not to just delete everything with syncTarget == carddav (or != local)?<br>
</div>
<div><br>
</div>
Thanks,<br>
</div>
Eli<br>
<br>
</div>
Stats:<br>
987    aggregate<br>
23128    carddav<br>
1419    google<br>
930    local<br>
2    sim<br>
65    telepathy<br>
2    voicemail<br>
3    was_local<br>
<br>
</div>
What does 'was_local' mean?<br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<br>
</div>
</div>
______________________________<wbr>_________________<br>
SailfishOS.org Devel mailing list<br>
To unsubscribe, please send a mail to <a href="redir.aspx?REF=B6rHUtjGDFWxj3PjttvFsgbqUMXnpHIP6b1jNnXiNBw_3yaE-2HUCAFtYWlsdG86ZGV2ZWwtdW5zdWJzY3JpYmVAbGlzdHMuc2FpbGZpc2hvcy5vcmc." target="_blank">
devel-unsubscribe@lists.sailfi<wbr>shos.org</a><br>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</blockquote>
</div>
</div>
</div>
<br>
</div>
</div>
</blockquote>
</div>
</div>
</div>
<br>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</div>
</div>
</body>
</html>