[evolution-data-server/gnome-3-0-3: 1/3] Bug #655253 - fix regression introduced with MOD_ONLY_THIS



commit e5c485ae6288620a46141458f9bd4007b46e5cd1
Author: Patrick Ohly <patrick ohly intel com>
Date:   Wed Sep 14 17:05:42 2011 +0200

    Bug #655253 - fix regression introduced with MOD_ONLY_THIS
    
    Part of the code reorganization was removal of check_dup_uid() from
    the normal "add component" code paths. It was only done as sanity
    check when loading a file. That sanity check then incorrectly rewrote
    UIDs, because it didn't take into account that detached recurrences
    have (and must have) the same UID as the recurring master event.
    
    This patch fixes check_dup_uid() accordingly. It moves the
    uid g_free() into the bottom of the function to have a common
    cleanup section.

 calendar/backends/file/e-cal-backend-file.c |   29 +++++++++++++++++++++++---
 1 files changed, 25 insertions(+), 4 deletions(-)
---
diff --git a/calendar/backends/file/e-cal-backend-file.c b/calendar/backends/file/e-cal-backend-file.c
index a33df12..85853f8 100644
--- a/calendar/backends/file/e-cal-backend-file.c
+++ b/calendar/backends/file/e-cal-backend-file.c
@@ -472,14 +472,19 @@ resolve_tzid (const gchar *tzid, gpointer user_data)
 	return zone;
 }
 
-/* Checks if the specified component has a duplicated UID and if so changes it */
+/* Checks if the specified component has a duplicated UID and if so changes it.
+ * UIDs may be shared between components if there is at most one component
+ * without RECURRENCE-ID (master) and all others have different RECURRENCE-ID
+ * values.
+ */
 static void
 check_dup_uid (ECalBackendFile *cbfile, ECalComponent *comp)
 {
 	ECalBackendFilePrivate *priv;
 	ECalBackendFileObject *obj_data;
 	const gchar *uid = NULL;
-	gchar *new_uid;
+	gchar *new_uid = NULL;
+	gchar *rid = NULL;
 
 	priv = cbfile->priv;
 
@@ -494,17 +499,33 @@ check_dup_uid (ECalBackendFile *cbfile, ECalComponent *comp)
 	if (!obj_data)
 		return; /* Everything is fine */
 
-	d(g_message (G_STRLOC ": Got object with duplicated UID `%s', changing it...", uid));
+	rid = e_cal_component_get_recurid_as_string (comp);
+	if (rid && *rid) {
+		/* new component has rid, must not be the same as in other detached recurrence */
+		if (!g_hash_table_lookup (obj_data->recurrences, rid))
+			goto done;
+	} else {
+		/* new component has no rid, must not clash with existing master */
+		if (!obj_data->full_object)
+			goto done;
+	}
+
+	d(g_message (G_STRLOC ": Got object with duplicated UID `%s' and rid `%s', changing it...",
+		     uid,
+		     rid ? rid : ""));
 
 	new_uid = e_cal_component_gen_uid ();
 	e_cal_component_set_uid (comp, new_uid);
-	g_free (new_uid);
 
 	/* FIXME: I think we need to reset the SEQUENCE property and reset the
 	 * CREATED/DTSTAMP/LAST-MODIFIED.
 	 */
 
 	save (cbfile);
+
+ done:
+	g_free (rid);
+	g_free (new_uid);
 }
 
 static struct icaltimetype



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]