commit 246c417874823c634fafc9135183c8fde0e195b8
Author: Oswald Buddenhagen <o...@users.sf.net>
Date:   Sun May 17 16:28:55 2015 +0200

    validate Path earlier
    
    we cannot know whether it will be needed later, but we can validate it
    if it's set.

 src/drv_maildir.c |   23 +++++++++++++++++------
 1 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/src/drv_maildir.c b/src/drv_maildir.c
index 59a40d2..b336ba9 100644
--- a/src/drv_maildir.c
+++ b/src/drv_maildir.c
@@ -169,15 +169,21 @@ maildir_join_path( maildir_store_conf_t *conf, const char 
*prefix, const char *b
 }
 
 static int
-maildir_validate_path( maildir_store_conf_t *conf )
+maildir_ensure_path( maildir_store_conf_t *conf )
 {
-       struct stat st;
-
        if (!conf->gen.path) {
                error( "Maildir error: store '%s' has no Path\n", 
conf->gen.name );
                conf->failed = FAIL_FINAL;
                return -1;
        }
+       return 0;
+}
+
+static int
+maildir_validate_path( maildir_store_conf_t *conf )
+{
+       struct stat st;
+
        if (stat( conf->gen.path, &st ) || !S_ISDIR(st.st_mode)) {
                error( "Maildir error: cannot open store '%s'\n", 
conf->gen.path );
                conf->failed = FAIL_FINAL;
@@ -199,8 +205,13 @@ maildir_open_store( store_conf_t *gconf, const char *label 
ATTR_UNUSED,
        ctx->gen.conf = gconf;
        ctx->uvfd = -1;
        init_wakeup( &ctx->lcktmr, lcktmr_timeout, ctx );
+       if (gconf->path && maildir_validate_path( conf ) < 0) {
+               free( ctx );
+               cb( 0, aux );
+               return;
+       }
        if (gconf->trash) {
-               if (maildir_validate_path( conf ) < 0) {
+               if (maildir_ensure_path( conf ) < 0) {
                        free( ctx );
                        cb( 0, aux );
                        return;
@@ -373,7 +384,7 @@ maildir_list_path( store_t *gctx, int flags, const char 
*inbox )
 {
        char path[_POSIX_PATH_MAX], name[_POSIX_PATH_MAX];
 
-       if (maildir_validate_path( (maildir_store_conf_t *)gctx->conf ) < 0)
+       if (maildir_ensure_path( (maildir_store_conf_t *)gctx->conf ) < 0)
                return -1;
        return maildir_list_recurse(
                gctx, 0, flags, inbox, inbox ? strlen( inbox ) : 0, 0, 0,
@@ -1113,7 +1124,7 @@ maildir_select_box( store_t *gctx, const char *name )
                gctx->path = maildir_join_path( conf, conf->inbox, name + 5 );
                ctx->is_inbox = !name[5];
        } else {
-               if (maildir_validate_path( conf ) < 0) {
+               if (maildir_ensure_path( conf ) < 0) {
                        gctx->path = 0;
                        return DRV_CANCELED;
                }

------------------------------------------------------------------------------
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

Reply via email to