Tired of hunting down deleted maildirs and folders this patch for
maildrop will automagically create/recreate missing directories.
For this to work one has to use maildrop for delivery (duh!) and
specify the target (DEFAULT) with a trailing slash (.Maildir/) or
a slash-dot (.../.foldername/.) as used in SQWebmail-filters.
I dont think there are any problems with this new functionality,
and wont mind if it gets integrated into the distribution ;)
(dont destroy the tabs in the patch wile copy&paste)
# fix missing Maildir/Folder if specified with trailing slash[dot]
--- ../courier-0.43.0.orig/maildrop/maildir.C Sun Aug 10 01:14:59 2003
+++ maildrop/maildir.C Sat Aug 30 19:09:37 2003
@@ -47,33 +47,57 @@
//
////////////////////////////////////////////////////////////////////////////
+// PATCH: check/fix Maildir
+int _MaildirCheckFix(const char *dir, int autocreate)
+{
+struct stat stat_buf;
+
+ // check if directory exists
+ if (! stat(dir, &stat_buf) ) return( S_ISDIR(stat_buf.st_mode) );
+ if (! autocreate) return(0); // legacy fallback
+ fprintf(stderr, "DEBUG maildrop: mkdir %s\n", dir);
+ if (! mkdir(dir, 0700) ) return(1); // success
+ merr << "maildrop: mkdir " << dir << ": " << strerror(errno) << "\n";
+ return(0);
+}
+
int Maildir::IsMaildir(const char *name)
{
Buffer dirname;
Buffer subdirname;
-struct stat stat_buf;
-
int c;
if (!name || !*name) return (0); // Nope, not a Maildir
dirname=name;
c=dirname.pop();
- if (c != SLASH_CHAR) dirname.push(c); // Strip trailing /
+ // PATCH: also strip trailing /. as used in SQWebmail filters
+ if (c == '.') c=dirname.pop(); // ugly
+ if (c != SLASH_CHAR)
+ {
+ dirname.push(c); // Strip trailing /
+ c = 0;
+ }
+
+ // PATCH: create/fix Maildir if specified with trailing slash[dot]
+ subdirname=dirname;
+ subdirname += '\0';
+ if(! _MaildirCheckFix( (const char *)subdirname, c) ) return(0);
+
subdirname=dirname;
subdirname += "/tmp";
subdirname += '\0';
- if ( stat( (const char *)subdirname, &stat_buf ) ||
- ! S_ISDIR(stat_buf.st_mode) ) return (0);
+ if(! _MaildirCheckFix( (const char *)subdirname, c) ) return(0);
+
subdirname=dirname;
subdirname += "/new";
subdirname += '\0';
- if ( stat( (const char *)subdirname, &stat_buf ) ||
- ! S_ISDIR(stat_buf.st_mode) ) return (0);
+ if(! _MaildirCheckFix( (const char *)subdirname, c) ) return(0);
+
subdirname=dirname;
subdirname += "/cur";
subdirname += '\0';
- if ( stat( (const char *)subdirname, &stat_buf ) ||
- ! S_ISDIR(stat_buf.st_mode) ) return (0);
+ if(! _MaildirCheckFix( (const char *)subdirname, c) ) return(0);
+
return (1); // If it looks like a duck, walks like a duck...
}
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
courier-users mailing list
[EMAIL PROTECTED]
Unsubscribe: https://lists.sourceforge.net/lists/listinfo/courier-users