Skip to content

Commit

Permalink
lib-storage: Do not drop autocreate boxes when listing them
Browse files Browse the repository at this point in the history
Otherwise we skip folders, because array_delete() is removing boxes while they're being iterated.
  • Loading branch information
cmouse authored and GitLab committed May 18, 2017
1 parent 78c3c40 commit da0b850
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/lib-storage/list/mailbox-list-iter.c
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit da0b850

Please sign in to comment.