Re: [PATCH] nmbug: write tags out to a temporary file, not 'nmbug.index'

Subject: Re: [PATCH] nmbug: write tags out to a temporary file, not 'nmbug.index'

Date: Sun, 13 Feb 2022 10:00:40 +0200

To: Sean Whitton, notmuch@notmuchmail.org

Cc: Sean Whitton

From: Tomi Ollila


On Sun, Feb 13 2022, Sean Whitton wrote:

> If more than nmbug process is running at once, then each will try to
> read and write the same file.  The particular failure I've seen is
> that the process which finishes first deletes nmbug.index, and then
> the other process dies with a FileNotFoundError.  So use a distinct
> temporary file per process.
> ---
>  devel/nmbug/nmbug | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/devel/nmbug/nmbug b/devel/nmbug/nmbug
> index 043c1863..3c069701 100755
> --- a/devel/nmbug/nmbug
> +++ b/devel/nmbug/nmbug
> @@ -603,8 +603,8 @@ def get_status():
>  
>  
>  def _index_tags():
> -    "Write notmuch tags to the nmbug.index."
> -    path = _os.path.join(NMBGIT, 'nmbug.index')
> +    "Write notmuch tags to a temporary index."
> +    (_ , path) = _tempfile.mkstemp()
>      query = ' '.join('tag:"{tag}"'.format(tag=tag) for tag in get_tags())
>      prefix = '+{0}'.format(_ENCODED_TAG_PREFIX)
>      _git(

Looks like a good idea. Looked a bit when the index file is removed; it
is but intermediate error could leave stray index file(s) around. The
current version in git always uses the same file, but now with this
temporary files some of those could be left hanging around...

Tomi

> -- 
> 2.30.2
_______________________________________________
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-leave@notmuchmail.org

Thread: