dovecot-2.2: dsync: Don't try to find mailboxes from unwanted na...

dovecot at dovecot.org dovecot at dovecot.org
Mon Jun 24 22:26:05 EEST 2013


details:   http://hg.dovecot.org/dovecot-2.2/rev/84014270ee37
changeset: 16540:84014270ee37
user:      Timo Sirainen <tss at iki.fi>
date:      Mon Jun 24 22:25:47 2013 +0300
description:
dsync: Don't try to find mailboxes from unwanted namespaces.

diffstat:

 src/doveadm/dsync/dsync-brain-mailbox-tree.c |  23 -----------------------
 src/doveadm/dsync/dsync-brain-mailbox.c      |   2 ++
 src/doveadm/dsync/dsync-brain.c              |  23 +++++++++++++++++++++++
 src/doveadm/dsync/dsync-brain.h              |   3 +++
 4 files changed, 28 insertions(+), 23 deletions(-)

diffs (101 lines):

diff -r b5876fa03b0e -r 84014270ee37 src/doveadm/dsync/dsync-brain-mailbox-tree.c
--- a/src/doveadm/dsync/dsync-brain-mailbox-tree.c	Mon Jun 24 16:37:48 2013 +0300
+++ b/src/doveadm/dsync/dsync-brain-mailbox-tree.c	Mon Jun 24 22:25:47 2013 +0300
@@ -2,7 +2,6 @@
 
 #include "lib.h"
 #include "str.h"
-#include "settings-parser.h"
 #include "mail-namespace.h"
 #include "doveadm-settings.h"
 #include "dsync-ibc.h"
@@ -11,28 +10,6 @@
 
 #include <ctype.h>
 
-static bool dsync_brain_want_namespace(struct dsync_brain *brain,
-				       struct mail_namespace *ns)
-{
-	if (brain->sync_ns != NULL)
-		return brain->sync_ns == ns;
-	if (ns->alias_for != NULL) {
-		/* always skip aliases */
-		return FALSE;
-	}
-	if (brain->sync_visible_namespaces) {
-		if ((ns->flags & NAMESPACE_FLAG_HIDDEN) == 0)
-			return TRUE;
-		if ((ns->flags & (NAMESPACE_FLAG_LIST_PREFIX |
-				  NAMESPACE_FLAG_LIST_CHILDREN)) != 0)
-			return TRUE;
-		return FALSE;
-	} else {
-		return strcmp(ns->unexpanded_set->location,
-			      SETTING_STRVAR_UNEXPANDED) == 0;
-	}
-}
-
 static void dsync_brain_check_namespaces(struct dsync_brain *brain)
 {
 	struct mail_namespace *ns, *first_ns = NULL;
diff -r b5876fa03b0e -r 84014270ee37 src/doveadm/dsync/dsync-brain-mailbox.c
--- a/src/doveadm/dsync/dsync-brain-mailbox.c	Mon Jun 24 16:37:48 2013 +0300
+++ b/src/doveadm/dsync/dsync-brain-mailbox.c	Mon Jun 24 22:25:47 2013 +0300
@@ -50,6 +50,8 @@
 	}
 
 	for (ns = brain->user->namespaces; ns != NULL; ns = ns->next) {
+		if (!dsync_brain_want_namespace(brain, ns))
+			continue;
 		if ((ret = ns_mailbox_try_alloc(ns, guid, box_r)) != 0) {
 			if (ret < 0)
 				brain->failed = TRUE;
diff -r b5876fa03b0e -r 84014270ee37 src/doveadm/dsync/dsync-brain.c
--- a/src/doveadm/dsync/dsync-brain.c	Mon Jun 24 16:37:48 2013 +0300
+++ b/src/doveadm/dsync/dsync-brain.c	Mon Jun 24 22:25:47 2013 +0300
@@ -6,6 +6,7 @@
 #include "hostpid.h"
 #include "str.h"
 #include "process-title.h"
+#include "settings-parser.h"
 #include "master-service.h"
 #include "master-service-settings.h"
 #include "mail-namespace.h"
@@ -584,3 +585,25 @@
 {
 	return brain->changes_during_sync;
 }
+
+bool dsync_brain_want_namespace(struct dsync_brain *brain,
+				struct mail_namespace *ns)
+{
+	if (brain->sync_ns != NULL)
+		return brain->sync_ns == ns;
+	if (ns->alias_for != NULL) {
+		/* always skip aliases */
+		return FALSE;
+	}
+	if (brain->sync_visible_namespaces) {
+		if ((ns->flags & NAMESPACE_FLAG_HIDDEN) == 0)
+			return TRUE;
+		if ((ns->flags & (NAMESPACE_FLAG_LIST_PREFIX |
+				  NAMESPACE_FLAG_LIST_CHILDREN)) != 0)
+			return TRUE;
+		return FALSE;
+	} else {
+		return strcmp(ns->unexpanded_set->location,
+			      SETTING_STRVAR_UNEXPANDED) == 0;
+	}
+}
diff -r b5876fa03b0e -r 84014270ee37 src/doveadm/dsync/dsync-brain.h
--- a/src/doveadm/dsync/dsync-brain.h	Mon Jun 24 16:37:48 2013 +0300
+++ b/src/doveadm/dsync/dsync-brain.h	Mon Jun 24 22:25:47 2013 +0300
@@ -70,5 +70,8 @@
 enum dsync_brain_sync_type dsync_brain_get_sync_type(struct dsync_brain *brain);
 /* Returns TRUE if there were any unexpected changes during the sync. */
 bool dsync_brain_has_unexpected_changes(struct dsync_brain *brain);
+/* Returns TRUE if we want to sync this namespace. */
+bool dsync_brain_want_namespace(struct dsync_brain *brain,
+				struct mail_namespace *ns);
 
 #endif


More information about the dovecot-cvs mailing list