Re: Add support for specifying tags during "notmuch new"

Subject: Re: Add support for specifying tags during "notmuch new"

Date: Fri, 02 May 2014 16:32:50 +0100

To: Austin Clements

Cc: notmuch@notmuchmail.org

From: David Edmondson


On Fri, May 02 2014, Austin Clements wrote:
>>     2) A periodic mail processing script wants to add new messages to
>>        the database, then process those newly added messages to add
>>        convenience tags, etc. without worrying about the user or other
>>        instances of the script manipulating tags at the same time. Use
>>        this approach:
>>          KEY=$RANDOM
>> 	 notmuch new +$KEY
>> 	 notmuch tag +notmuch tag:$KEY and to:notmuch@notmuchmail.org
>> 	 notmuch tag +gnus tag:$KEY and to:ding@gnus.org
>> 	 ...
>> 	 notmuch tag -$KEY tag:$KEY
>
> What happens when this script dies in the middle (say, your computer
> loses power or notmuch tag conflicts with something else on the write
> lock)?

It's a problem. I think that I would actually add both 'new' and
'new-$seconds' tags (given that I can't search on wildcarded tags) and
have 'notmuch tag' use only 'new-$seconds'.

The 'new' tag would help recover from failures such as you describe.

> One advantage of the standard "new" tag approach is that it's easy to
> write a stateless post-new tagging script that can be killed at any
> point and restarted.  (You're right that post-new has a concurrency
> issue, but we should fix that in its own right.)
signature.asc (application/pgp-signature)

Thread: