From: Timo Sirainen Date: Thu, 25 Sep 2025 07:40:40 +0000 (+0300) Subject: lib-storage: mailbox_list_ns_prefix_return() - Move subscription checks to be last X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5cbdd47a54c9366e2550989f0f1b169bed058f7e;p=thirdparty%2Fdovecot%2Fcore.git lib-storage: mailbox_list_ns_prefix_return() - Move subscription checks to be last This will be needed by the following changes. --- diff --git a/src/lib-storage/list/mailbox-list-iter.c b/src/lib-storage/list/mailbox-list-iter.c index 9dd25c2b85..60c5c93ee8 100644 --- a/src/lib-storage/list/mailbox-list-iter.c +++ b/src/lib-storage/list/mailbox-list-iter.c @@ -516,24 +516,17 @@ mailbox_list_ns_prefix_return(struct ns_list_iterate_context *ctx, i_assert(!ctx->inbox_listed); ctx->inbox_listed = TRUE; ctx->ns_info.flags |= ctx->inbox_info.flags | MAILBOX_SELECT; + } else { + /* see if namespace prefix is selectable */ + box = mailbox_alloc(ns->list, ctx->ns_info.vname, 0); + if (mailbox_exists(box, TRUE, &existence) == 0 && + existence == MAILBOX_EXISTENCE_SELECT) + ctx->ns_info.flags |= MAILBOX_SELECT; + else + ctx->ns_info.flags |= MAILBOX_NONEXISTENT; + mailbox_free(&box); } - if ((ctx->ctx.flags & (MAILBOX_LIST_ITER_RETURN_SUBSCRIBED | - MAILBOX_LIST_ITER_SELECT_SUBSCRIBED)) != 0) { - /* Refresh subscriptions first, this won't cause a duplicate - call later on as this is only called when the namespace's - children definitely don't match */ - if (mailbox_list_iter_subscriptions_refresh(ns->list) < 0) { - mailbox_list_ns_iter_failed(ctx); - return FALSE; - } - mailbox_list_set_subscription_flags(ns->list, - ctx->ns_info.vname, - &ctx->ns_info.flags); - } - if (!mailbox_ns_prefix_check_selection_criteria(ctx)) - return FALSE; - /* see if the namespace has children */ if (has_children) ctx->ns_info.flags |= MAILBOX_CHILDREN; @@ -552,17 +545,20 @@ mailbox_list_ns_prefix_return(struct ns_list_iterate_context *ctx, } } - if ((ctx->ns_info.flags & MAILBOX_SELECT) == 0) { - /* see if namespace prefix is selectable */ - box = mailbox_alloc(ns->list, ctx->ns_info.vname, 0); - if (mailbox_exists(box, TRUE, &existence) == 0 && - existence == MAILBOX_EXISTENCE_SELECT) - ctx->ns_info.flags |= MAILBOX_SELECT; - else - ctx->ns_info.flags |= MAILBOX_NONEXISTENT; - mailbox_free(&box); + if ((ctx->ctx.flags & (MAILBOX_LIST_ITER_RETURN_SUBSCRIBED | + MAILBOX_LIST_ITER_SELECT_SUBSCRIBED)) != 0) { + /* Refresh subscriptions first, this won't cause a duplicate + call later on as this is only called when the namespace's + children definitely don't match */ + if (mailbox_list_iter_subscriptions_refresh(ns->list) < 0) { + mailbox_list_ns_iter_failed(ctx); + return FALSE; + } + mailbox_list_set_subscription_flags(ns->list, + ctx->ns_info.vname, + &ctx->ns_info.flags); } - return TRUE; + return mailbox_ns_prefix_check_selection_criteria(ctx); } static void inbox_set_children_flags(struct ns_list_iterate_context *ctx)