dovecot-2.2: dsync: Don't unnecessarily try to create all the ma...

dovecot at dovecot.org dovecot at dovecot.org
Wed Feb 27 11:47:20 EET 2013


details:   http://hg.dovecot.org/dovecot-2.2/rev/fe170fd8168e
changeset: 15983:fe170fd8168e
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Feb 27 11:47:08 2013 +0200
description:
dsync: Don't unnecessarily try to create all the mailboxes when they already exist.

diffstat:

 src/doveadm/dsync/dsync-mailbox-tree-sync.c |  25 +++++++++++++++++--------
 1 files changed, 17 insertions(+), 8 deletions(-)

diffs (45 lines):

diff -r 6bebab0d5c02 -r fe170fd8168e src/doveadm/dsync/dsync-mailbox-tree-sync.c
--- a/src/doveadm/dsync/dsync-mailbox-tree-sync.c	Wed Feb 27 11:21:48 2013 +0200
+++ b/src/doveadm/dsync/dsync-mailbox-tree-sync.c	Wed Feb 27 11:47:08 2013 +0200
@@ -990,7 +990,17 @@
 		other_node = hash_table_lookup(other_tree->guid_hash, guid_p);
 		if (other_node == NULL)
 			other_node = sorted_tree_get(other_tree, name);
-		if (!dsync_mailbox_node_is_dir(other_node)) {
+		if (dsync_mailbox_node_is_dir(other_node)) {
+			/* create a missing mailbox */
+			other_node->existence = DSYNC_MAILBOX_NODE_EXISTS;
+			other_node->ns = node->ns;
+			other_node->uid_validity = node->uid_validity;
+			memcpy(other_node->mailbox_guid, node->mailbox_guid,
+			       sizeof(other_node->mailbox_guid));
+			if (other_tree == ctx->local_tree)
+				sync_add_create_change(ctx, other_node, name);
+		} else if (!guid_128_equals(node->mailbox_guid,
+					    other_node->mailbox_guid)) {
 			/* mailbox with same name exists both locally and
 			   remotely, but they have different GUIDs and neither
 			   side has the other's GUID. typically this means that
@@ -998,16 +1008,15 @@
 			   INBOX). we'll just change the GUID for one of
 			   them. */
 			i_assert(node->existence == DSYNC_MAILBOX_NODE_EXISTS);
+			i_assert(node->ns == other_node->ns);
+
 			if (other_tree == ctx->local_tree)
 				sync_add_create_change(ctx, node, name);
 		} else {
-			other_node->existence = DSYNC_MAILBOX_NODE_EXISTS;
-			other_node->ns = node->ns;
-			other_node->uid_validity = node->uid_validity;
-			memcpy(other_node->mailbox_guid, node->mailbox_guid,
-			       sizeof(other_node->mailbox_guid));
-			if (other_tree == ctx->local_tree)
-				sync_add_create_change(ctx, other_node, name);
+			/* existing mailbox. mismatching UIDVALIDITY is handled
+			   later while syncing the mailbox. */
+			i_assert(node->existence == DSYNC_MAILBOX_NODE_EXISTS);
+			i_assert(node->ns == other_node->ns);
 		}
 	}
 	dsync_mailbox_tree_iter_deinit(&iter);


More information about the dovecot-cvs mailing list