dovecot-2.2: dsync: Added back support for syncing only one mail...
dovecot at dovecot.org
dovecot at dovecot.org
Sat Dec 15 13:01:29 EET 2012
details: http://hg.dovecot.org/dovecot-2.2/rev/88ac919f8afe
changeset: 15471:88ac919f8afe
user: Timo Sirainen <tss at iki.fi>
date: Sat Dec 15 13:01:09 2012 +0200
description:
dsync: Added back support for syncing only one mailbox (-m parameter)
diffstat:
src/doveadm/dsync/doveadm-dsync.c | 2 +-
src/doveadm/dsync/dsync-brain-mailbox-tree.c | 5 ++---
src/doveadm/dsync/dsync-brain-private.h | 1 +
src/doveadm/dsync/dsync-brain.c | 5 ++++-
src/doveadm/dsync/dsync-brain.h | 2 +-
src/doveadm/dsync/dsync-ibc-pipe.c | 1 +
src/doveadm/dsync/dsync-ibc-stream.c | 6 +++++-
src/doveadm/dsync/dsync-ibc.h | 2 ++
src/doveadm/dsync/dsync-mailbox-tree-fill.c | 7 ++++---
src/doveadm/dsync/dsync-mailbox-tree.h | 5 +++--
10 files changed, 24 insertions(+), 12 deletions(-)
diffs (206 lines):
diff -r 01ba0511d04d -r 88ac919f8afe src/doveadm/dsync/doveadm-dsync.c
--- a/src/doveadm/dsync/doveadm-dsync.c Sat Dec 15 12:31:56 2012 +0200
+++ b/src/doveadm/dsync/doveadm-dsync.c Sat Dec 15 13:01:09 2012 +0200
@@ -373,7 +373,7 @@
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);
diff -r 01ba0511d04d -r 88ac919f8afe src/doveadm/dsync/dsync-brain-mailbox-tree.c
--- a/src/doveadm/dsync/dsync-brain-mailbox-tree.c Sat Dec 15 12:31:56 2012 +0200
+++ b/src/doveadm/dsync/dsync-brain-mailbox-tree.c Sat Dec 15 13:01:09 2012 +0200
@@ -76,14 +76,14 @@
/* 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;
}
}
@@ -92,7 +92,6 @@
dsync_mailbox_tree_iter_init(brain->local_mailbox_tree);
}
-
void dsync_brain_send_mailbox_tree(struct dsync_brain *brain)
{
struct dsync_mailbox_node *node;
diff -r 01ba0511d04d -r 88ac919f8afe src/doveadm/dsync/dsync-brain-private.h
--- a/src/doveadm/dsync/dsync-brain-private.h Sat Dec 15 12:31:56 2012 +0200
+++ b/src/doveadm/dsync/dsync-brain-private.h Sat Dec 15 13:01:09 2012 +0200
@@ -46,6 +46,7 @@
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;
diff -r 01ba0511d04d -r 88ac919f8afe src/doveadm/dsync/dsync-brain.c
--- a/src/doveadm/dsync/dsync-brain.c Sat Dec 15 12:31:56 2012 +0200
+++ b/src/doveadm/dsync/dsync-brain.c Sat Dec 15 13:01:09 2012 +0200
@@ -83,7 +83,7 @@
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)
@@ -99,6 +99,7 @@
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);
@@ -120,6 +121,7 @@
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 |
@@ -183,6 +185,7 @@
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);
diff -r 01ba0511d04d -r 88ac919f8afe src/doveadm/dsync/dsync-brain.h
--- a/src/doveadm/dsync/dsync-brain.h Sat Dec 15 12:31:56 2012 +0200
+++ b/src/doveadm/dsync/dsync-brain.h Sat Dec 15 13:01:09 2012 +0200
@@ -28,7 +28,7 @@
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);
diff -r 01ba0511d04d -r 88ac919f8afe src/doveadm/dsync/dsync-ibc-pipe.c
--- a/src/doveadm/dsync/dsync-ibc-pipe.c Sat Dec 15 12:31:56 2012 +0200
+++ b/src/doveadm/dsync/dsync-ibc-pipe.c Sat Dec 15 13:01:09 2012 +0200
@@ -157,6 +157,7 @@
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
diff -r 01ba0511d04d -r 88ac919f8afe src/doveadm/dsync/dsync-ibc-stream.c
--- a/src/doveadm/dsync/dsync-ibc-stream.c Sat Dec 15 12:31:56 2012 +0200
+++ b/src/doveadm/dsync/dsync-ibc-stream.c Sat Dec 15 13:01:09 2012 +0200
@@ -60,7 +60,7 @@
{ 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",
@@ -514,6 +514,8 @@
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) {
@@ -574,6 +576,8 @@
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':
diff -r 01ba0511d04d -r 88ac919f8afe src/doveadm/dsync/dsync-ibc.h
--- a/src/doveadm/dsync/dsync-ibc.h Sat Dec 15 12:31:56 2012 +0200
+++ b/src/doveadm/dsync/dsync-ibc.h Sat Dec 15 13:01:09 2012 +0200
@@ -31,6 +31,8 @@
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;
diff -r 01ba0511d04d -r 88ac919f8afe src/doveadm/dsync/dsync-mailbox-tree-fill.c
--- a/src/doveadm/dsync/dsync-mailbox-tree-fill.c Sat Dec 15 12:31:56 2012 +0200
+++ b/src/doveadm/dsync/dsync-mailbox-tree-fill.c Sat Dec 15 13:01:09 2012 +0200
@@ -170,7 +170,7 @@
}
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;
@@ -181,6 +181,7 @@
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);
@@ -195,7 +196,7 @@
}
/* 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;
@@ -206,7 +207,7 @@
}
/* 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;
diff -r 01ba0511d04d -r 88ac919f8afe src/doveadm/dsync/dsync-mailbox-tree.h
--- a/src/doveadm/dsync/dsync-mailbox-tree.h Sat Dec 15 12:31:56 2012 +0200
+++ b/src/doveadm/dsync/dsync-mailbox-tree.h Sat Dec 15 13:01:09 2012 +0200
@@ -121,9 +121,10 @@
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 *
More information about the dovecot-cvs
mailing list