Commit 4a5a1c42 authored by Sriram Karra's avatar Sriram Karra

Fix CD sync to use get_itemid_from_synctags at folder level

parent 32768db9
......@@ -74,7 +74,7 @@ class CDContact(Contact):
CREATED = 'X-ASYNK-CREATED'
SYNC_TAG_PREFIX = 'X-ASYNK-SYNCTAG-'
def __init__ (self, folder, con=None, vco=None, itemid=None,
def __init__ (self, folder, con=None, con_itemid=None, vco=None, itemid=None,
debug_vcf=False):
"""vco, if not None, should be a valid vCard object (i.e. the contents
of a vCard file, for e.g. When vco is not None, itemid should also be
......@@ -89,22 +89,12 @@ class CDContact(Contact):
self.set_vco(vco)
self._group_count = 0
## Sometimes we might be creating a contact object from a Google
## contact object or other entry which might have the ID in its sync
## tags field. if that is present, we should use it to initialize the
## itemid field for the current object
conf = self.get_config()
if con:
try:
pname_re = conf.get_profile_name_re()
label = conf.make_sync_label(pname_re, self.get_dbid())
tag, itemid = con.get_sync_tags(label)[0]
self.set_itemid(self.normalize_cdid(itemid))
except Exception, e:
if con_itemid:
self.set_itemid(self.normalize_cdid(con_itemid))
else:
logging.debug('Potential new CDContact: %s', con.get_name())
elif vco:
self.init_props_from_vco(vco)
if not self.debug_vcf:
......
......@@ -205,7 +205,8 @@ class CDContactsFolder(Folder):
## to PUT the damn items one at a time. What kind of a standard is
## this, anyway?
cd = CDContact(self, con=item)
con_itemid = item.get_itemid_from_synctags(pname, 'cd')
cd = CDContact(self, con=item, con_itemid=con_itemid)
cd.update_sync_tags(src_sync_tag, item.get_itemid(), save=True)
self.add_contact(cd)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment