isync

mailbox synchronization program
git clone https://git.code.sf.net/p/isync/isync
Log | Files | Refs | README | LICENSE

commit 2d4ce72a8b164f04c059ca4a446e340f2919f086
parent 41ed1012241c30c265109ca187bfe6751ed19828
Author: Oswald Buddenhagen <ossi@users.sf.net>
Date:   Sat, 18 Apr 2015 11:42:00 +0200

make handling of Inbox-in-Path nesting less obfuscated

when we run into Inbox while listing Path, check whether Inbox is being
listed anyway, and just skip it if so, instead of listing it right away
and resetting LIST_INBOX (and thus having a calling order dependency).

Diffstat:
Msrc/drv_maildir.c | 16++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/drv_maildir.c b/src/drv_maildir.c @@ -228,10 +228,10 @@ maildir_invoke_bad_callback( store_t *ctx ) ctx->bad_callback( ctx->bad_callback_aux ); } -static int maildir_list_inbox( store_t *gctx, int *flags ); +static int maildir_list_inbox( store_t *gctx, int flags ); static int -maildir_list_recurse( store_t *gctx, int isBox, int *flags, const char *inbox, int inboxLen, +maildir_list_recurse( store_t *gctx, int isBox, int flags, const char *inbox, int inboxLen, char *path, int pathLen, char *name, int nameLen ) { DIR *dir; @@ -258,7 +258,8 @@ maildir_list_recurse( store_t *gctx, int isBox, int *flags, const char *inbox, i const char *ent = de->d_name; pl = pathLen + nfsnprintf( path + pathLen, _POSIX_PATH_MAX - pathLen, "%s", ent ); if (inbox && equals( path, pl, inbox, inboxLen )) { - if (maildir_list_inbox( gctx, flags ) < 0) { + /* Inbox nested into Path. List now if it won't be listed separately anyway. */ + if (!(flags & LIST_INBOX) && maildir_list_inbox( gctx, flags ) < 0) { closedir( dir ); return -1; } @@ -290,11 +291,10 @@ maildir_list_recurse( store_t *gctx, int isBox, int *flags, const char *inbox, i } static int -maildir_list_inbox( store_t *gctx, int *flags ) +maildir_list_inbox( store_t *gctx, int flags ) { char path[_POSIX_PATH_MAX], name[_POSIX_PATH_MAX]; - *flags &= ~LIST_INBOX; return maildir_list_recurse( gctx, 2, flags, 0, 0, path, nfsnprintf( path, _POSIX_PATH_MAX, "%s", ((maildir_store_conf_t *)gctx->conf)->inbox ), @@ -302,7 +302,7 @@ maildir_list_inbox( store_t *gctx, int *flags ) } static int -maildir_list_path( store_t *gctx, int *flags ) +maildir_list_path( store_t *gctx, int flags ) { const char *inbox = ((maildir_store_conf_t *)gctx->conf)->inbox; char path[_POSIX_PATH_MAX], name[_POSIX_PATH_MAX]; @@ -319,8 +319,8 @@ static void maildir_list_store( store_t *gctx, int flags, void (*cb)( int sts, void *aux ), void *aux ) { - if (((flags & LIST_PATH) && maildir_list_path( gctx, &flags ) < 0) || - ((flags & LIST_INBOX) && maildir_list_inbox( gctx, &flags ) < 0)) { + if (((flags & LIST_PATH) && maildir_list_path( gctx, flags ) < 0) || + ((flags & LIST_INBOX) && maildir_list_inbox( gctx, flags ) < 0)) { maildir_invoke_bad_callback( gctx ); cb( DRV_CANCELED, aux ); } else {