]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Do not drop autocreate boxes when listing them
authorAki Tuomi <aki.tuomi@dovecot.fi>
Wed, 17 May 2017 09:16:31 +0000 (12:16 +0300)
committerVille Savolainen <ville.savolainen@dovecot.fi>
Fri, 9 Jun 2017 07:21:29 +0000 (10:21 +0300)
Otherwise we skip folders, because array_delete() is removing boxes while they're being iterated.

src/lib-storage/list/mailbox-list-iter.c

index 89aaa51fb31bfafc25679fb295d8fe2cafc45b51..f53446f2ac07859be30519dd6846d6227d27549a 100644 (file)
@@ -31,6 +31,7 @@ struct mailbox_list_autocreate_iterate_context {
        ARRAY(struct autocreate_box) boxes;
        ARRAY_TYPE(mailbox_settings) box_sets;
        ARRAY_TYPE(mailbox_settings) all_ns_box_sets;
+       bool listing_autoboxes:1;
 };
 
 struct ns_list_iterate_context {
@@ -828,7 +829,8 @@ autocreate_iter_existing(struct mailbox_list_iterate_context *ctx)
        match = autocreate_box_match(&actx->box_sets, ctx->list->ns,
                                     info->vname, FALSE, &idx);
 
-       if ((match & AUTOCREATE_MATCH_RESULT_YES) != 0) {
+       if (!actx->listing_autoboxes &&
+           (match & AUTOCREATE_MATCH_RESULT_YES) != 0) {
                /* we have an exact match in the list.
                   don't list it at the end. */
                array_delete(&actx->boxes, idx, 1);
@@ -993,6 +995,9 @@ mailbox_list_iter_default_next(struct mailbox_list_iterate_context *ctx)
        if (actx == NULL)
                return NULL;
 
+       /* do not drop boxes anymore */
+       actx->listing_autoboxes = TRUE;
+
        /* list missing mailboxes */
        autoboxes = array_get(&actx->boxes, &count);
        while (actx->idx < count) {