commit a7eddc6ede4d52589aae2626885dc6793836bf9c
Author: Oswald Buddenhagen <[email protected]>
Date:   Sat Jan 17 15:27:08 2015 +0100

    don't make intermediate directories proper maildirs
    
    "phantom" mailboxes waste time on syncing. furthermore, mutt's mailbox
    navigator provides no means to enter subfolders of maildirs.

 src/drv_maildir.c |   41 ++++++++++++++++++++++++++---------------
 1 files changed, 26 insertions(+), 15 deletions(-)

diff --git a/src/drv_maildir.c b/src/drv_maildir.c
index fee333e..0a4ea9f 100644
--- a/src/drv_maildir.c
+++ b/src/drv_maildir.c
@@ -214,22 +214,22 @@ maildir_list_recurse( store_t *gctx, int isBox, int 
*flags, const char *inbox, i
                       char *path, int pathLen, char *name, int nameLen )
 {
        DIR *dir;
-       int pl, nl, missing;
+       int pl, nl;
        struct dirent *de;
        struct stat st;
 
        if (isBox) {
                path[pathLen++] = '/';
-               nfsnprintf( path + pathLen, _POSIX_PATH_MAX - pathLen, "cur" );
-               missing = stat( path, &st ) || !S_ISDIR(st.st_mode);
-               if (!missing || isBox > 1)
+               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 );
-               if (missing)
-                       return 0;
                path[pathLen] = 0;
                name[nameLen++] = '/';
        }
        if (!(dir = opendir( path ))) {
+               if (isBox && (errno == ENOENT || errno == ENOTDIR))
+                       return 0;
                sys_error( "Maildir error: cannot list %s", path );
                return -1;
        }
@@ -369,9 +369,27 @@ maildir_clear_tmp( char *buf, int bufsz, int bl )
 }
 
 static int
-maildir_validate( const char *box, int create, maildir_store_t *ctx )
+make_box_dir( char *buf, int bl )
 {
        char *p;
+
+       if (!mkdir( buf, 0700 ) || errno == EEXIST)
+               return 0;
+       p = memrchr( buf, '/', bl - 1 );
+       if (*(p + 1) != '.') {
+               errno = ENOENT;
+               return -1;
+       }
+       *p = 0;
+       if (make_box_dir( buf, (int)(p - buf) ))
+               return -1;
+       *p = '/';
+       return mkdir( buf, 0700 );
+}
+
+static int
+maildir_validate( const char *box, int create, maildir_store_t *ctx )
+{
        int i, bl, ret;
        struct stat st;
        char buf[_POSIX_PATH_MAX];
@@ -384,14 +402,7 @@ maildir_validate( const char *box, int create, 
maildir_store_t *ctx )
                }
                if (!create)
                        return DRV_BOX_BAD;
-               p = memrchr( buf, '/', bl - 1 );
-               if (*(p + 1) == '.') {
-                       *p = 0;
-                       if ((ret = maildir_validate( buf, 1, ctx )) != DRV_OK)
-                               return ret;
-                       *p = '/';
-               }
-               if (mkdir( buf, 0700 )) {
+               if (make_box_dir( buf, bl )) {
                        sys_error( "Maildir error: cannot create mailbox '%s'", 
box );
                        maildir_invoke_bad_callback( &ctx->gen );
                        return DRV_CANCELED;

------------------------------------------------------------------------------
New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
GigeNET is offering a free month of service with a new server in Ashburn.
Choose from 2 high performing configs, both with 100TB of bandwidth.
Higher redundancy.Lower latency.Increased capacity.Completely compliant.
http://p.sf.net/sfu/gigenet
_______________________________________________
isync-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/isync-devel

Reply via email to