commit 5f4e3b285eb444b4bd01606d6ceb57f77ad282dd
Author: Oswald Buddenhagen <[email protected]>
Date:   Mon Dec 29 02:00:18 2014 +0100

    factor out maildir_clear_tmp()

 src/drv_maildir.c |   58 ++++++++++++++++++++++++++------------------
 1 files changed, 34 insertions(+), 24 deletions(-)

diff --git a/src/drv_maildir.c b/src/drv_maildir.c
index 443d4cc..dcc5fde 100644
--- a/src/drv_maildir.c
+++ b/src/drv_maildir.c
@@ -336,12 +336,42 @@ maildir_free_scan( msglist_t *msglist )
 #define _24_HOURS (3600 * 24)
 
 static int
-maildir_validate( const char *box, int create, maildir_store_t *ctx )
+maildir_clear_tmp( char *buf, int bufsz, int bl )
 {
        DIR *dirp;
        struct dirent *entry;
-       char *p;
        time_t now;
+       struct stat st;
+
+       memcpy( buf + bl, "tmp/", 5 );
+       bl += 4;
+       if (!(dirp = opendir( buf ))) {
+               sys_error( "Maildir error: cannot list %s", buf );
+               return DRV_BOX_BAD;
+       }
+       time( &now );
+       while ((entry = readdir( dirp ))) {
+               nfsnprintf( buf + bl, bufsz - bl, "%s", entry->d_name );
+               if (stat( buf, &st )) {
+                       if (errno != ENOENT)
+                               sys_error( "Maildir error: cannot access %s", 
buf );
+               } else if (S_ISREG(st.st_mode) && now - st.st_ctime >= 
_24_HOURS) {
+                       /* This should happen infrequently enough that it won't 
be
+                        * bothersome to the user to display when it occurs.
+                        */
+                       info( "Maildir notice: removing stale file %s\n", buf );
+                       if (unlink( buf ) && errno != ENOENT)
+                               sys_error( "Maildir error: cannot remove %s", 
buf );
+               }
+       }
+       closedir( dirp );
+       return DRV_OK;
+}
+
+static int
+maildir_validate( const char *box, int create, maildir_store_t *ctx )
+{
+       char *p;
        int i, bl, ret;
        struct stat st;
        char buf[_POSIX_PATH_MAX];
@@ -386,28 +416,8 @@ maildir_validate( const char *box, int create, 
maildir_store_t *ctx )
                                return DRV_BOX_BAD;
                        }
                }
-               memcpy( buf + bl, "tmp/", 5 );
-               bl += 4;
-               if (!(dirp = opendir( buf ))) {
-                       sys_error( "Maildir error: cannot list %s", buf );
-                       return DRV_BOX_BAD;
-               }
-               time( &now );
-               while ((entry = readdir( dirp ))) {
-                       nfsnprintf( buf + bl, sizeof(buf) - bl, "%s", 
entry->d_name );
-                       if (stat( buf, &st )) {
-                               if (errno != ENOENT)
-                                       sys_error( "Maildir error: cannot 
access %s", buf );
-                       } else if (S_ISREG(st.st_mode) && now - st.st_ctime >= 
_24_HOURS) {
-                               /* this should happen infrequently enough that 
it won't be
-                                * bothersome to the user to display when it 
occurs.
-                                */
-                               info( "Maildir notice: removing stale file 
%s\n", buf );
-                               if (unlink( buf ) && errno != ENOENT)
-                                       sys_error( "Maildir error: cannot 
remove %s", buf );
-                       }
-               }
-               closedir( dirp );
+               if ((ret = maildir_clear_tmp( buf, sizeof(buf), bl )) != DRV_OK)
+                       return ret;
                ctx->fresh = 0;
        }
        return DRV_OK;

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