dovecot-2.0: dsync: Handle missing mail GUIDs.

dovecot at dovecot.org dovecot at dovecot.org
Sat Jul 18 03:11:10 EEST 2009


details:   http://hg.dovecot.org/dovecot-2.0/rev/16849c0931be
changeset: 9644:16849c0931be
user:      Timo Sirainen <tss at iki.fi>
date:      Fri Jul 17 20:11:05 2009 -0400
description:
dsync: Handle missing mail GUIDs.

diffstat:

2 files changed, 13 insertions(+), 2 deletions(-)
src/dsync/dsync-brain.c      |   10 ++++++++--
src/dsync/test-dsync-brain.c |    5 +++++

diffs (42 lines):

diff -r 3b285975bb15 -r 16849c0931be src/dsync/dsync-brain.c
--- a/src/dsync/dsync-brain.c	Fri Jul 17 20:09:22 2009 -0400
+++ b/src/dsync/dsync-brain.c	Fri Jul 17 20:11:05 2009 -0400
@@ -225,6 +225,8 @@ get_guid_128_str(const char *guid, unsig
 
 	buffer_create_data(&guid_128_buf, dest, dest_len);
 	mail_generate_guid_128_hash(guid, guid_128);
+	if (mail_guid_128_is_empty(guid_128))
+		return "";
 	binary_to_hex_append(&guid_128_buf, guid_128, sizeof(guid_128));
 	buffer_append_c(&guid_128_buf, '\0');
 	return guid_128_buf.data;
@@ -274,8 +276,12 @@ static int dsync_brain_msg_sync_pair(str
 		return 0;
 	}
 
-	/* UIDs match, but do GUIDs? */
-	if (strcmp(src_guid, dest_guid) != 0) {
+	/* UIDs match, but do GUIDs? If either of the GUIDs aren't set, it
+	   means that either the storage doesn't support GUIDs or we're
+	   handling an old-style expunge record. In that case just assume
+	   they match. */
+	if (strcmp(src_guid, dest_guid) != 0 &&
+	    *src_guid != '\0' && *dest_guid != '\0') {
 		/* UID conflict. give new UIDs to messages in both src and
 		   dest (if they're not expunged already) */
 		sync->uid_conflict = TRUE;
diff -r 3b285975bb15 -r 16849c0931be src/dsync/test-dsync-brain.c
--- a/src/dsync/test-dsync-brain.c	Fri Jul 17 20:09:22 2009 -0400
+++ b/src/dsync/test-dsync-brain.c	Fri Jul 17 20:11:05 2009 -0400
@@ -94,6 +94,11 @@ void mail_generate_guid_128_hash(const c
 
 	sha1_get_digest(guid, strlen(guid), sha1_sum);
 	memcpy(guid_128, sha1_sum, MAIL_GUID_128_SIZE);
+}
+
+bool mail_guid_128_is_empty(const uint8_t guid_128[MAIL_GUID_128_SIZE] ATTR_UNUSED)
+{
+	return FALSE;
 }
 
 static bool mailbox_find(const char *name, unsigned int *idx_r)


More information about the dovecot-cvs mailing list