procmail
[Top] [All Lists]

Re: create nested maildirs as needed before creating a lock file?

2010-12-15 12:55:44
On Wed, December 15, 2010 1:07 pm, Harald Dunkel wrote:

Hi folks,

Is there some magic to tell procmail to create nested maildirs as
necessary _before_ it tries to set a lock?

I found a lot of messages like this in the procmail log:

procmail: Locking "harri/mailing
lists/vger.kernel.org/a/b/c/linux-kernel/.lock"
procmail: Error while writing to "harri/mailing
lists/vger.kernel.org/a/b/c/linux-kernel/__rB+_tPCNB.sylvester.afaics."


The procmailrc entry was:

:0:
* ^(From|Cc:|To:)(_dot_)*linux-kernel(_at_)vger\(_dot_)kernel\(_dot_)org
$LOGNAME/mailing\ lists/vger.kernel.org/a/b/c/linux-kernel/


The "a/b/c/linux-kernel" subdirectory tree did not exist in
this test case. It would be very nice if procmail could create
the missing nested directories automagically.


If you know the possible directory trees beforehand then just create them.

If you don't and the tree is going to be based on some information from
the message's header then extract that information into a variable and
test for the existence of the appropriate directory structure and create
it if necessary.

e.g. (untested):
:0
* ^Subject: \/FATAL.*
{
  DIRTREE=$LOGNAME/mailing_lists/$MATCH

 :0
 * ! ? test -d $DIRTREE || mkdir $DIRTREE
 {
#fail if couldn't create the needed
    EXITCODE=127
    HOST
 }

 :0
 $DIRTREE/
}

Rich

____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)de
http://mailman.rwth-aachen.de/mailman/listinfo/procmail