dovecot-2.2: dsync: Allow -m parameter to specify \Special-use m...
dovecot at dovecot.org
dovecot at dovecot.org
Tue Jan 20 02:48:11 UTC 2015
details: http://hg.dovecot.org/dovecot-2.2/rev/ba0b94f11cea
changeset: 18184:ba0b94f11cea
user: Timo Sirainen <tss at iki.fi>
date: Tue Jan 20 04:46:51 2015 +0200
description:
dsync: Allow -m parameter to specify \Special-use mailboxes.
Similarly to how -x parameter allows them.
diffstat:
src/doveadm/dsync/dsync-mailbox-tree-fill.c | 31 ++++++++++++++++++++--------
1 files changed, 22 insertions(+), 9 deletions(-)
diffs (74 lines):
diff -r b505739970e7 -r ba0b94f11cea src/doveadm/dsync/dsync-mailbox-tree-fill.c
--- a/src/doveadm/dsync/dsync-mailbox-tree-fill.c Tue Jan 20 04:46:26 2015 +0200
+++ b/src/doveadm/dsync/dsync-mailbox-tree-fill.c Tue Jan 20 04:46:51 2015 +0200
@@ -268,17 +268,28 @@
}
static bool
-dsync_mailbox_info_is_excluded(const struct mailbox_info *info,
- const char *const *exclude_mailboxes)
+dsync_mailbox_info_is_wanted(const struct mailbox_info *info,
+ const char *box_name,
+ const char *const *exclude_mailboxes)
{
const char *const *info_specialuses;
unsigned int i;
- if (exclude_mailboxes == NULL)
- return FALSE;
+ if (exclude_mailboxes == NULL &&
+ (box_name == NULL || box_name[0] != '\\'))
+ return TRUE;
info_specialuses = info->special_use == NULL ? NULL :
t_strsplit(info->special_use, " ");
+ /* include */
+ if (box_name != NULL && box_name[0] == '\\') {
+ if (info_specialuses == NULL ||
+ !str_array_icase_find(info_specialuses, box_name))
+ return FALSE;
+ }
+ /* exclude */
+ if (exclude_mailboxes == NULL)
+ return TRUE;
for (i = 0; exclude_mailboxes[i] != NULL; i++) {
const char *exclude = exclude_mailboxes[i];
@@ -286,14 +297,14 @@
/* special-use */
if (info_specialuses != NULL &&
str_array_icase_find(info_specialuses, exclude))
- return TRUE;
+ return FALSE;
} else {
/* mailbox with wildcards */
if (wildcard_match(info->vname, exclude))
- return TRUE;
+ return FALSE;
}
}
- return FALSE;
+ return TRUE;
}
int dsync_mailbox_tree_fill(struct dsync_mailbox_tree *tree,
@@ -314,7 +325,8 @@
struct mailbox_list_iterate_context *iter;
struct dsync_mailbox_node *node, *dup_node1, *dup_node2;
const struct mailbox_info *info;
- const char *list_pattern = box_name != NULL ? box_name : "*";
+ const char *list_pattern =
+ box_name != NULL && box_name[0] != '\\' ? box_name : "*";
int ret = 0;
i_assert(mail_namespace_get_sep(ns) == tree->sep);
@@ -331,7 +343,8 @@
/* first add all of the existing mailboxes */
iter = mailbox_list_iter_init(ns->list, list_pattern, list_flags);
while ((info = mailbox_list_iter_next(iter)) != NULL) T_BEGIN {
- if (!dsync_mailbox_info_is_excluded(info, exclude_mailboxes)) {
+ if (dsync_mailbox_info_is_wanted(info, box_name,
+ exclude_mailboxes)) {
if (dsync_mailbox_tree_add(tree, info, box_guid) < 0)
ret = -1;
}
More information about the dovecot-cvs
mailing list