[evolution-data-server/gnome-3-16] Bug 752304 - [WebDAV book] Generated UIDs can clash with existing
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server/gnome-3-16] Bug 752304 - [WebDAV book] Generated UIDs can clash with existing
- Date: Tue, 14 Jul 2015 16:48:38 +0000 (UTC)
commit a26e0011905ec2578fc815a37f510ba7674addb0
Author: Milan Crha <mcrha redhat com>
Date: Tue Jul 14 18:44:37 2015 +0200
Bug 752304 - [WebDAV book] Generated UIDs can clash with existing
.../backends/webdav/e-book-backend-webdav.c | 16 +++++++++++++---
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 438f3f5..f5ceb06 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) */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]