[Dovecot] dsync 2.1.10 does not correctly handle renames of mailbox subtrees

Karol Jurak karol.jurak at gmail.com
Wed Feb 13 13:22:12 EET 2013


On 13 February 2013 11:46, Timo Sirainen <tss at iki.fi> wrote:

> On 12.2.2013, at 11.19, Karol Jurak <karol.jurak at gmail.com> wrote:
>
> > It seems that dsync 2.1.10 does not correctly handle renames of mailbox
> > subtrees. The scenario is as follows.
>
> I'm hoping I won't have to fix this in v2.1. v2.2 has a redesigned dsync
> where rename syncing should work much better.
>
>
Would you mind taking a look at the following patch? It appends to
dovecot.mailbox.log records describing
renames of all mailboxes in a subtree, not just the top level one. My basic
tests showed that this indeed allows
dsync to correctly replicate the renames, but I'm not familiar with dovecot
internals enough to be confident that this
doesn't break something else.

diff --git a/src/lib-storage/index/index-storage.c
b/src/lib-storage/index/index-storage.c
index 6d0771c..292c0fa 100644
--- a/src/lib-storage/index/index-storage.c
+++ b/src/lib-storage/index/index-storage.c
@@ -584,6 +584,9 @@ int index_storage_mailbox_rename(struct mailbox *src,
struct mailbox *dest,
                                 bool rename_children)
 {
        guid_128_t guid;
+       struct mailbox_list_iterate_context *iter;
+       const char *pattern;
+       const struct mailbox_info *info;

        if (src->list->v.rename_mailbox(src->list, src->name,
                                        dest->list, dest->name,
@@ -596,6 +599,23 @@ int index_storage_mailbox_rename(struct mailbox *src,
struct mailbox *dest,
           non-selectable mailbox (directory), which doesn't even have a
GUID */
        mailbox_name_get_sha128(dest->name, guid);
        mailbox_list_add_change(src->list, MAILBOX_LOG_RECORD_RENAME, guid);
+
+       if (rename_children) {
+               pattern = t_strdup_printf("%s%c*", dest->name,
+                       mail_namespace_get_sep(dest->list->ns));
+
+               iter = mailbox_list_iter_init(dest->list, pattern,
+                       MAILBOX_LIST_ITER_RETURN_NO_FLAGS);
+
+               while ((info = mailbox_list_iter_next(iter)) != NULL) {
+                       mailbox_name_get_sha128(info->name, guid);
+                       mailbox_list_add_change(src->list,
MAILBOX_LOG_RECORD_RENAME,
+                               guid);
+               }
+
+               mailbox_list_iter_deinit(&iter);
+       }
+
        return 0;
 }


More information about the dovecot mailing list