From 2d1cfc2c7f7262d578b4e52b904c9e471937e2a4 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Sun, 19 Mar 2017 20:21:19 +0100 Subject: [PATCH] make "Patterns *" match INBOX* in Maildir++ Stores this also has the side effect that we won't fail to include INBOX itself when Inbox is nested under Path when using other SubFolder styles (regression introduced with Maildir++ support in 0f24ca31b). REFMAIL: 1489492069.2148187.910409864.7727F9FC@webmail.messagingengine.com --- src/drv_maildir.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/drv_maildir.c b/src/drv_maildir.c index 327f39e..d933779 100644 --- a/src/drv_maildir.c +++ b/src/drv_maildir.c @@ -400,8 +400,7 @@ maildir_list_inbox( store_t *gctx, int flags, const char *basePath ) { char path[_POSIX_PATH_MAX], name[_POSIX_PATH_MAX]; - if (flags & LIST_INBOX) - add_string_list( &gctx->boxes, "INBOX" ); + add_string_list( &gctx->boxes, "INBOX" ); return maildir_list_recurse( gctx, 1, flags, 0, 0, basePath, basePath ? strlen( basePath ) - 1 : 0, path, nfsnprintf( path, _POSIX_PATH_MAX, "%s/", ((maildir_store_conf_t *)gctx->conf)->inbox ), @@ -426,10 +425,18 @@ maildir_list_store( store_t *gctx, int flags, void (*cb)( int sts, void *aux ), void *aux ) { maildir_store_conf_t *conf = (maildir_store_conf_t *)gctx->conf; - if (((((flags & LIST_PATH) && conf->sub_style != SUB_MAILDIRPP) - || ((flags & LIST_PATH_MAYBE) && gctx->conf->path)) + + // The Maildir++ Inbox is technically not under Path, so "*" would + // never match INBOX*, which is rather unintuitive. Matching INBOX* + // implicitly instead makes it consistent with an IMAP Store with + // an empty Path. + if (conf->sub_style == SUB_MAILDIRPP) + flags |= LIST_INBOX; + + if ((conf->sub_style != SUB_MAILDIRPP + && ((flags & LIST_PATH) || ((flags & LIST_PATH_MAYBE) && gctx->conf->path)) && maildir_list_path( gctx, flags, conf->inbox ) < 0) || - (((flags & LIST_INBOX) || conf->sub_style == SUB_MAILDIRPP) + ((flags & LIST_INBOX) && maildir_list_inbox( gctx, flags, gctx->conf->path ) < 0)) { maildir_invoke_bad_callback( gctx ); cb( DRV_CANCELED, aux );