On Fri, Mar 03, 2006 at 11:10:22PM -0500, Steve Shockley wrote:
> I'm using relaydb to scan through my mailbox (maildir format) to 
> whitelist and blacklist.  I do something like this in my Inbox:
> 
> for message in $MAILBASE/cur/*
> do
> cat $message | /usr/local/bin/relaydb -vwf /var/spamd/relaydb
> done
> 
> The problem with this is that I keep messages in my Inbox; so, every 
> time relaydb runs, it increments the white counter for all the messages, 
> not just the ones it hasn't seen.
> 
> Is there any way to make relaydb only work on those files/messages that 
> it hasn't previously seen?

LASTDBCHECK=/some/where/permanent/.lastdbcheck
if [ -e $LASTDBCHECK ]; then
        CHECK_LASTDB="-cnewer $LASTDBCHECK";
else
        CHECK_LASTDB='';
fi
find $MAILBASE/cur -type f $CHECK_LASTDB -exec /usr/local/bin/relaydb \
        -vwf /var/spamd/relaydb {} \;
touch $LASTDBCHECK

Or whatever the syntax for relaydb should be.

Note that this is not perfect - most notably, it will not catch all
messages arriving between the start of the find command and the touch
command. A more perfect solution would involve keeping lists of
processed files and only calling relaydb on those files that are in the
new one and not in the old one. This is not too difficult, using find >
$TMPFILE, a file containing the find results from last run, and diff
-u | sed -ne 's/^+//p'.

However, something as simple as the above is likely to be good enough.

                Joachim

Reply via email to