commit acd6b4b0b89d8e706f1463c97582868dec3c190b Author: Oswald Buddenhagen <o...@users.sf.net> Date: Fri Jun 3 15:38:35 2022 +0200
simplify/fix recursive maildir listing there is no need to call maildir_list_{path,inbox}() from maildir_list_recurse(), as maildir_list_store() will do that anyway - if it's actually requested, that is. this means that this removes the implicit listing when Inbox is nested into Path, or vice versa. this is actually correct, as the Patterns matching would throw away the non- requested boxes anyway. src/drv_maildir.c | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/src/drv_maildir.c b/src/drv_maildir.c index 9eac0d5d..0f94519c 100644 --- a/src/drv_maildir.c +++ b/src/drv_maildir.c @@ -363,9 +363,6 @@ maildir_list_maildirpp( maildir_store_t *ctx, int flags, const char *inbox ) return 0; } -static int maildir_list_inbox( maildir_store_t *ctx, int flags, const char *basePath ); -static int maildir_list_path( maildir_store_t *ctx, int flags, const char *inbox ); - static int maildir_list_recurse( maildir_store_t *ctx, int isBox, int flags, const char *inbox, uint inboxLen, const char *basePath, uint basePathLen, @@ -405,16 +402,8 @@ maildir_list_recurse( maildir_store_t *ctx, int isBox, int flags, pl += pathLen; if (inbox && equals( path, pl, inbox, inboxLen )) { // Inbox nested into Path. - if (maildir_list_inbox( ctx, flags, NULL ) < 0) { - closedir( dir ); - return -1; - } } else if (basePath && equals( path, pl, basePath, basePathLen )) { // Path nested into Inbox. - if (maildir_list_path( ctx, flags, NULL ) < 0) { - closedir( dir ); - return -1; - } } else { if (style == SUB_LEGACY) { if (*ent == '.') { @@ -453,7 +442,7 @@ maildir_list_recurse( maildir_store_t *ctx, int isBox, int flags, } static int -maildir_list_inbox( maildir_store_t *ctx, int flags, const char *basePath ) +maildir_list_inbox( maildir_store_t *ctx, int flags ) { char path[_POSIX_PATH_MAX], name[_POSIX_PATH_MAX]; @@ -462,6 +451,7 @@ maildir_list_inbox( maildir_store_t *ctx, int flags, const char *basePath ) ctx->listed |= LIST_INBOX; add_string_list( &ctx->boxes, "INBOX" ); + const char *basePath = ctx->conf->path; return maildir_list_recurse( ctx, 1, flags, NULL, 0, basePath, basePath ? strlen( basePath ) - 1 : 0, path, nfsnprintf( path, _POSIX_PATH_MAX, "%s/", ctx->conf->inbox ), @@ -469,7 +459,7 @@ maildir_list_inbox( maildir_store_t *ctx, int flags, const char *basePath ) } static int -maildir_list_path( maildir_store_t *ctx, int flags, const char *inbox ) +maildir_list_path( maildir_store_t *ctx, int flags ) { char path[_POSIX_PATH_MAX], name[_POSIX_PATH_MAX]; @@ -479,8 +469,9 @@ maildir_list_path( maildir_store_t *ctx, int flags, const char *inbox ) if (maildir_ensure_path( ctx->conf ) < 0) return -1; + const char *inbox = ctx->conf->inbox; return maildir_list_recurse( - ctx, 0, flags, inbox, inbox ? strlen( inbox ) : 0, NULL, 0, + ctx, 0, flags, inbox, strlen( inbox ), NULL, 0, path, nfsnprintf( path, _POSIX_PATH_MAX, "%s", ctx->conf->path ), name, 0 ); } @@ -495,9 +486,9 @@ maildir_list_store( store_t *gctx, int flags, if (conf->sub_style == SUB_MAILDIRPP ? maildir_list_maildirpp( ctx, flags, conf->inbox ) < 0 : ((((flags & LIST_PATH) || ((flags & LIST_PATH_MAYBE) && conf->path)) - && maildir_list_path( ctx, flags, conf->inbox ) < 0) || + && maildir_list_path( ctx, flags ) < 0) || ((flags & LIST_INBOX) - && maildir_list_inbox( ctx, flags, conf->path ) < 0))) { + && maildir_list_inbox( ctx, flags ) < 0))) { maildir_invoke_bad_callback( ctx ); cb( DRV_CANCELED, NULL, aux ); } else { _______________________________________________ isync-devel mailing list isync-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/isync-devel