changeset 11733:529e85c548a9 HEAD

dsync: Detect duplicate mailbox GUIDs and fail if it happens.
author Timo Sirainen <tss@iki.fi>
date Mon, 05 Jul 2010 15:29:07 +0100
parents 8f6703ce6528
children ba9f33f9c6c3
files src/dsync/dsync-worker-local.c
diffstat 1 files changed, 12 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/dsync/dsync-worker-local.c	Mon Jul 05 15:04:54 2010 +0100
+++ b/src/dsync/dsync-worker-local.c	Mon Jul 05 15:29:07 2010 +0100
@@ -480,6 +480,7 @@
 	uint8_t mailbox_guid[MAIL_GUID_128_SIZE];
 	struct local_dsync_mailbox_change *change;
 	struct local_dsync_dir_change *dir_change, change_lookup;
+	struct local_dsync_mailbox *old_lbox;
 	const char *const *fields;
 	unsigned int i, field_count;
 
@@ -550,6 +551,17 @@
 		array_append(&dsync_box_r->cache_fields, &field_name, 1);
 	}
 
+	old_lbox = hash_table_lookup(worker->mailbox_hash,
+				     &dsync_box_r->mailbox_guid);
+	if (old_lbox != NULL) {
+		i_error("Mailboxes don't have unique GUIDs: "
+			"%s is shared by %s and %s",
+			dsync_guid_to_str(&dsync_box_r->mailbox_guid),
+			old_lbox->storage_name, storage_name);
+		mailbox_free(&box);
+		_iter->failed = TRUE;
+		return -1;
+	}
 	local_dsync_worker_add_mailbox(worker, info->ns, storage_name,
 				       &dsync_box_r->mailbox_guid);
 	mailbox_free(&box);