From: Timo Sirainen Date: Sun, 4 May 2008 20:43:18 +0000 (+0300) Subject: maildir++ LIST (subscribed): If listing finds a non-subscribed mailbox under X-Git-Tag: 1.1.rc5~9 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=05a55ef683eba78d6e210b9676341a51696d01f8;p=thirdparty%2Fdovecot%2Fcore.git maildir++ LIST (subscribed): If listing finds a non-subscribed mailbox under a subscribed one, mark the subscribed one as having children. --HG-- branch : HEAD --- diff --git a/src/lib-storage/list/mailbox-list-maildir-iter.c b/src/lib-storage/list/mailbox-list-maildir-iter.c index 6ba60ca550..255769289d 100644 --- a/src/lib-storage/list/mailbox-list-maildir-iter.c +++ b/src/lib-storage/list/mailbox-list-maildir-iter.c @@ -89,6 +89,33 @@ maildir_fill_parents(struct maildir_list_iterate_context *ctx, } } +static void maildir_set_children(struct maildir_list_iterate_context *ctx, + string_t *mailbox) +{ + struct mailbox_node *node; + const char *p, *mailbox_c; + char hierarchy_sep; + + if ((ctx->ctx.flags & MAILBOX_LIST_ITER_VIRTUAL_NAMES) != 0) + hierarchy_sep = ctx->ctx.list->ns->sep; + else + hierarchy_sep = ctx->ctx.list->ns->real_sep; + + /* mark the first existing parent as containing children */ + mailbox_c = str_c(mailbox); + while ((p = strrchr(mailbox_c, hierarchy_sep)) != NULL) { + str_truncate(mailbox, (size_t) (p-mailbox_c)); + mailbox_c = str_c(mailbox); + + node = mailbox_tree_lookup(ctx->tree_ctx, mailbox_c); + if (node != NULL) { + node->flags &= ~MAILBOX_NOCHILDREN; + node->flags |= MAILBOX_CHILDREN; + break; + } + } +} + static int maildir_fill_readdir(struct maildir_list_iterate_context *ctx, struct imap_match_glob *glob, bool update_only) @@ -191,6 +218,9 @@ maildir_fill_readdir(struct maildir_list_iterate_context *ctx, node->flags |= MAILBOX_MATCHED; node->flags |= flags; node_fix_parents(node); + } else { + i_assert(update_only); + maildir_set_children(ctx, mailbox); } } }