changeset 22104:48151d18f8cb

lib-storage: Do not drop autocreate boxes when listing them Otherwise we skip folders, because array_delete() is removing boxes while they're being iterated.
author Aki Tuomi <aki.tuomi@dovecot.fi>
date Wed, 17 May 2017 12:16:31 +0300
parents 1158025171fe
children 318a0fa3e49d
files src/lib-storage/list/mailbox-list-iter.c
diffstat 1 files changed, 6 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-storage/list/mailbox-list-iter.c	Thu Apr 06 16:09:00 2017 +0300
+++ b/src/lib-storage/list/mailbox-list-iter.c	Wed May 17 12:16:31 2017 +0300
@@ -31,6 +31,7 @@
 	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 @@
 	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 @@
 	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) {