summaryrefslogtreecommitdiff
path: root/addressbook
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2015-07-14 18:44:37 +0200
committerMilan Crha <mcrha@redhat.com>2015-07-14 18:44:37 +0200
commit4d4a97508e92b73cc46796b20acf112d95a8a934 (patch)
tree6e86d47a6284482f2afc655d3c474e42f4e595ef /addressbook
parentb9cab825e2358fd4a2a684bb2d86fc860f2604b9 (diff)
downloadevolution-data-server-4d4a97508e92b73cc46796b20acf112d95a8a934.tar.gz
Bug 752304 - [WebDAV book] Generated UIDs can clash with existing
Diffstat (limited to 'addressbook')
-rw-r--r--addressbook/backends/webdav/e-book-backend-webdav.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/addressbook/backends/webdav/e-book-backend-webdav.c b/addressbook/backends/webdav/e-book-backend-webdav.c
index 438f3f5c5..f5ceb06ef 100644
--- a/addressbook/backends/webdav/e-book-backend-webdav.c
+++ b/addressbook/backends/webdav/e-book-backend-webdav.c
@@ -1482,11 +1482,21 @@ book_backend_webdav_create_contacts_sync (EBookBackend *backend,
if (orig_uid && *orig_uid && !e_book_backend_cache_check_contact (webdav->priv->cache, orig_uid)) {
uid = g_strdup (orig_uid);
} else {
- /* do 3 rand() calls to construct a unique ID... poor way but should be
- * good enough for us */
- uid = g_strdup_printf ("%08X-%08X-%08X", rand (), rand (), rand ());
+ uid = NULL;
+
+ do {
+ g_free (uid);
+
+ /* do 3 random() calls to construct a unique ID... poor way but should be
+ * good enough for us */
+ uid = g_strdup_printf ("%08X-%08X-%08X", g_random_int (), g_random_int (), g_random_int ());
+
+ } while (e_book_backend_cache_check_contact (webdav->priv->cache, uid) &&
+ !g_cancellable_is_cancelled (cancellable));
+
e_contact_set (contact, E_CONTACT_UID, uid);
}
+
href = g_strconcat (webdav->priv->uri, uid, ".vcf", NULL);
/* kill WEBDAV_CONTACT_ETAG field (might have been set by some other backend) */