Re: create nested maildirs as needed before creating a lock file?
"R.G. Ball" <[email protected]>
| Newsgroups | gmane.mail.procmail |
|---|---|
| Message-ID | <[email protected]> |
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:).*linux-kernel@vger\.kernel\.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