commit 064f579a925fe45e77ee1389f0e2a0cc041bbf37 Author: Oswald Buddenhagen <o...@users.sf.net> Date: Fri May 1 17:29:22 2015 +0200
make maildir_list_recurse() recursion less convoluted move the unconditional addition of INBOX out ouf the function. this makes it possible to move the folder check and addition to the listing before the recursion, which seems clearer. src/drv_maildir.c | 22 ++++++++++------------ 1 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/drv_maildir.c b/src/drv_maildir.c index 6d3b483..509084f 100644 --- a/src/drv_maildir.c +++ b/src/drv_maildir.c @@ -243,15 +243,6 @@ maildir_list_recurse( store_t *gctx, int isBox, int flags, struct dirent *de; struct stat st; - if (isBox) { - path[pathLen++] = '/'; - if (isBox > 1 || - (nfsnprintf( path + pathLen, _POSIX_PATH_MAX - pathLen, "cur" ), - !stat( path, &st ) && S_ISDIR(st.st_mode))) - add_string_list( &gctx->boxes, name ); - path[pathLen] = 0; - name[nameLen++] = '/'; - } if (!(dir = opendir( path ))) { if (isBox && (errno == ENOENT || errno == ENOTDIR)) return 0; @@ -290,6 +281,12 @@ maildir_list_recurse( store_t *gctx, int isBox, int flags, } } nl = nameLen + nfsnprintf( name + nameLen, _POSIX_PATH_MAX - nameLen, "%s", ent ); + path[pl++] = '/'; + nfsnprintf( path + pl, _POSIX_PATH_MAX - pl, "cur" ); + if (!stat( path, &st ) && S_ISDIR(st.st_mode)) + add_string_list( &gctx->boxes, name ); + path[pl] = 0; + name[nl++] = '/'; if (maildir_list_recurse( gctx, 1, flags, inbox, inboxLen, basePath, basePathLen, path, pl, name, nl ) < 0) { closedir( dir ); return -1; @@ -305,10 +302,11 @@ maildir_list_inbox( store_t *gctx, int flags, const char *basePath ) { char path[_POSIX_PATH_MAX], name[_POSIX_PATH_MAX]; + add_string_list( &gctx->boxes, "INBOX" ); return maildir_list_recurse( - gctx, 2, flags, 0, 0, basePath, basePath ? strlen( basePath ) - 1 : 0, - path, nfsnprintf( path, _POSIX_PATH_MAX, "%s", ((maildir_store_conf_t *)gctx->conf)->inbox ), - name, nfsnprintf( name, _POSIX_PATH_MAX, "INBOX" ) ); + 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 ), + name, nfsnprintf( name, _POSIX_PATH_MAX, "INBOX/" ) ); } static int ------------------------------------------------------------------------------ One dashboard for servers and applications across Physical-Virtual-Cloud Widest out-of-the-box monitoring support with 50+ applications Performance metrics, stats and reports that give you Actionable Insights Deep dive visibility with transaction tracing using APM Insight. http://ad.doubleclick.net/ddm/clk/290420510;117567292;y _______________________________________________ isync-devel mailing list isync-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/isync-devel