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
This commit is contained in:
Oswald Buddenhagen 2017-03-19 20:21:19 +01:00
parent 763cb8341f
commit 2d1cfc2c7f

View File

@ -400,7 +400,6 @@ maildir_list_inbox( store_t *gctx, int flags, const char *basePath )
{ {
char path[_POSIX_PATH_MAX], name[_POSIX_PATH_MAX]; 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( return maildir_list_recurse(
gctx, 1, flags, 0, 0, basePath, basePath ? strlen( basePath ) - 1 : 0, gctx, 1, flags, 0, 0, basePath, basePath ? strlen( basePath ) - 1 : 0,
@ -426,10 +425,18 @@ maildir_list_store( store_t *gctx, int flags,
void (*cb)( int sts, void *aux ), void *aux ) void (*cb)( int sts, void *aux ), void *aux )
{ {
maildir_store_conf_t *conf = (maildir_store_conf_t *)gctx->conf; 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) || && 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_list_inbox( gctx, flags, gctx->conf->path ) < 0)) {
maildir_invoke_bad_callback( gctx ); maildir_invoke_bad_callback( gctx );
cb( DRV_CANCELED, aux ); cb( DRV_CANCELED, aux );