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

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

Date: Sun, 13 Feb 2022 00:24:41 -0700

To: notmuch@notmuchmail.org

Cc: Sean Whitton

From: Sean Whitton


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(
-- 
2.30.2

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

Thread: