if (doveadm_debug)
brain_flags |= DSYNC_BRAIN_FLAG_DEBUG;
- brain = dsync_brain_master_init(user, ibc, sync_ns,
+ brain = dsync_brain_master_init(user, ibc, sync_ns, ctx->mailbox,
ctx->sync_type, brain_flags,
ctx->state_input == NULL ? "" :
ctx->state_input);
/* fill the local mailbox tree */
if (brain->sync_ns != NULL) {
if (dsync_mailbox_tree_fill(brain->local_mailbox_tree,
- brain->sync_ns) < 0)
+ brain->sync_ns, brain->sync_box) < 0)
brain->failed = TRUE;
} else {
for (ns = brain->user->namespaces; ns != NULL; ns = ns->next) {
if (!dsync_brain_want_namespace(brain, ns))
continue;
if (dsync_mailbox_tree_fill(brain->local_mailbox_tree,
- ns) < 0)
+ ns, brain->sync_box) < 0)
brain->failed = TRUE;
}
}
dsync_mailbox_tree_iter_init(brain->local_mailbox_tree);
}
-
void dsync_brain_send_mailbox_tree(struct dsync_brain *brain)
{
struct dsync_mailbox_node *node;
struct mail_user *user;
struct dsync_ibc *ibc;
struct mail_namespace *sync_ns;
+ char *sync_box;
enum dsync_brain_sync_type sync_type;
char hierarchy_sep;
struct dsync_brain *
dsync_brain_master_init(struct mail_user *user, struct dsync_ibc *ibc,
- struct mail_namespace *sync_ns,
+ struct mail_namespace *sync_ns, const char *sync_box,
enum dsync_brain_sync_type sync_type,
enum dsync_brain_flags flags,
const char *state)
brain->sync_type = sync_type;
if (sync_ns != NULL)
brain->sync_ns = sync_ns;
+ brain->sync_box = p_strdup(brain->pool, sync_box);
brain->master_brain = TRUE;
dsync_brain_set_flags(brain, flags);
memset(&ibc_set, 0, sizeof(ibc_set));
ibc_set.sync_ns_prefix = sync_ns == NULL ? NULL : sync_ns->prefix;
+ ibc_set.sync_box = sync_box;
ibc_set.sync_type = sync_type;
/* reverse the backup direction for the slave */
ibc_set.brain_flags = flags & ~(DSYNC_BRAIN_FLAG_BACKUP_SEND |
brain->sync_ns = mail_namespace_find(brain->user->namespaces,
ibc_set->sync_ns_prefix);
}
+ brain->sync_box = p_strdup(brain->pool, ibc_set->sync_box);
i_assert(brain->sync_type == DSYNC_BRAIN_SYNC_TYPE_UNKNOWN);
brain->sync_type = ibc_set->sync_type;
dsync_brain_set_flags(brain, ibc_set->brain_flags);
struct dsync_brain *
dsync_brain_master_init(struct mail_user *user, struct dsync_ibc *ibc,
- struct mail_namespace *sync_ns,
+ struct mail_namespace *sync_ns, const char *sync_box,
enum dsync_brain_sync_type sync_type,
enum dsync_brain_flags flags,
const char *state);
item = dsync_ibc_pipe_push_item(pipe->remote, ITEM_HANDSHAKE);
item->u.set = *set;
item->u.set.sync_ns_prefix = p_strdup(item->pool, set->sync_ns_prefix);
+ item->u.set.sync_box = p_strdup(item->pool, set->sync_box);
}
static enum dsync_ibc_recv_ret
{ NULL, '\0', NULL, NULL },
{ .name = "handshake",
.chr = 'H',
- .optional_keys = "sync_ns_prefix sync_type debug sync_all_namespaces "
+ .optional_keys = "sync_ns_prefix sync_box sync_type debug sync_all_namespaces "
"mails_have_guids send_guid_requests backup_send backup_recv"
},
{ .name = "mailbox_state",
dsync_serializer_encode_add(encoder, "sync_ns_prefix",
set->sync_ns_prefix);
}
+ if (set->sync_box != NULL)
+ dsync_serializer_encode_add(encoder, "sync_box", set->sync_box);
sync_type[0] = sync_type[1] = '\0';
switch (set->sync_type) {
if (dsync_deserializer_decode_try(decoder, "sync_ns_prefix", &value))
set->sync_ns_prefix = p_strdup(pool, value);
+ if (dsync_deserializer_decode_try(decoder, "sync_box", &value))
+ set->sync_box = p_strdup(pool, value);
if (dsync_deserializer_decode_try(decoder, "sync_type", &value)) {
switch (value[0]) {
case 'f':
struct dsync_ibc_settings {
/* if non-NULL, sync only this namespace */
const char *sync_ns_prefix;
+ /* if non-NULL, sync only this mailbox name */
+ const char *sync_box;
enum dsync_brain_sync_type sync_type;
enum dsync_brain_flags brain_flags;
}
int dsync_mailbox_tree_fill(struct dsync_mailbox_tree *tree,
- struct mail_namespace *ns)
+ struct mail_namespace *ns, const char *box_name)
{
const enum mailbox_list_iter_flags list_flags =
MAILBOX_LIST_ITER_NO_AUTO_BOXES;
struct mailbox_list_iterate_context *iter;
struct dsync_mailbox_node *node;
const struct mailbox_info *info;
+ const char *list_pattern = box_name != NULL ? box_name : "*";
int ret = 0;
i_assert(mail_namespace_get_sep(ns) == tree->sep);
}
/* first add all of the existing mailboxes */
- iter = mailbox_list_iter_init(ns->list, "*", list_flags);
+ iter = mailbox_list_iter_init(ns->list, list_pattern, list_flags);
while ((info = mailbox_list_iter_next(iter)) != NULL) {
if (dsync_mailbox_tree_add(tree, info) < 0)
ret = -1;
}
/* add subscriptions */
- iter = mailbox_list_iter_init(ns->list, "*", subs_list_flags);
+ iter = mailbox_list_iter_init(ns->list, list_pattern, subs_list_flags);
while ((info = mailbox_list_iter_next(iter)) != NULL) {
if (dsync_mailbox_tree_add_node(tree, info, &node) < 0)
ret = -1;
void dsync_mailbox_node_copy_data(struct dsync_mailbox_node *dest,
const struct dsync_mailbox_node *src);
-/* Add nodes to tree from the given namespace. */
+/* Add nodes to tree from the given namespace. If box_name is non-NULL,
+ add only that mailbox to the tree. */
int dsync_mailbox_tree_fill(struct dsync_mailbox_tree *tree,
- struct mail_namespace *ns);
+ struct mail_namespace *ns, const char *box_name);
/* Return all known deleted mailboxes and directories. */
const struct dsync_mailbox_delete *