Due to the change in the config system, notmuch keeps a notmuch database
open when it would not do so before. Consequently, it can miss changes
to the database which are done from a hook (while notmuch holds the
databse in read only mode). When notmuch itself writes to the database
after that it uses wrong assumptions about the last used doc id etc.

Demonstrate this by triggering an assertion. (This new test succeeds
with notmuch 0.31.4.)

Signed-off-by: Michael J Gruber <g...@grubix.eu>
---
 test/T400-hooks.sh | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/test/T400-hooks.sh b/test/T400-hooks.sh
index 00c99337..58e2b1dd 100755
--- a/test/T400-hooks.sh
+++ b/test/T400-hooks.sh
@@ -28,6 +28,16 @@ EOF
     echo "${TOKEN}" > ${2}
 }
 
+create_change_hook () {
+    mkdir -p ${HOOK_DIR}
+    cat <<EOF >"${HOOK_DIR}/${1}"
+#!/bin/sh
+notmuch insert --no-hooks < ${2} > /dev/null
+rm -f ${2}
+EOF
+    chmod +x "${HOOK_DIR}/${1}"
+}
+
 create_failing_hook () {
     local HOOK_DIR=${2}
     mkdir -p ${HOOK_DIR}
@@ -176,6 +186,17 @@ EOF
     NOTMUCH_NEW
     test_expect_equal_file write.expected write.output
 
+    test_begin_subtest "pre-new with change in database [${config}]"
+    test_subtest_known_broken
+    rm -rf ${HOOK_DIR}
+    notmuch search '*' > change.expected
+    generate_message '[subject]="Inserted"'
+    create_change_hook "pre-new" $gen_msg_filename $HOOK_DIR
+    generate_message
+    NOTMUCH_NEW
+    output=$(notmuch search id:$gen_msg_id | notmuch_search_sanitize)
+    test_expect_equal "$output" "thread:XXX   2001-01-05 [1/1] Notmuch Test 
Suite; pre-new with change in database [${config}] (inbox unread)"
+
     rm -rf ${HOOK_DIR}
 done
 test_done
-- 
2.31.1.708.gc9a0ac0934
_______________________________________________
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org

Reply via email to