questions about post-new/insert hooks

Subject: questions about post-new/insert hooks

Date: Tue, 23 Dec 2014 13:48:02 -0800

To: Notmuch Mail

Cc:

From: Jameson Graef Rollins


Hi, folks.  I was wondering about possible race conditions in the
post-new hook.  Given that the database does not remain locked during
execution of the post-new hook, isn't there a possibility that more new
messages will be added to the database before the post-new hook has
finished processing?  If so, I can imagine multiple ways that might
break typical logic in post-new hooks.  I wonder if this race condition
could be avoided by e.g. sending the post-new hook the message ids of
all newly-added messages on stdin.  The hook could then use the message
ids to process just the new messages, without worrying that other
messages could have been added in the middle of processing.  Has anyone
thought about this?

I was also wondering about per-message insertion hooks.  The new(ish)
insert command has a post-insert hook which is run on a per-message
insertion basis.  What about adding a hook that would run on each
message being added with new?  This would also be a way to get rid of
the above mentioned race condition, and might allow for simpler message
content filtering for those of us using notmuch-new instead of
notmuch-insert.  Maybe in this the per-message hook could get the full
text of the message on stdin, and the message id as argument.

I haven't fully thought the implications of this stuff through, so I
would love to hear what others think.

The reason I bring all this up is that I'm trying to figure out the best
way to integrate spam classification into my notmuch setup, which for
some reason is currently proving exceedingly difficult.

jamie.
signature.asc (application/pgp-signature)

Thread: