Re: Database location bug when database does not already exist

Subject: Re: Database location bug when database does not already exist

Date: Mon, 25 Jul 2022 21:17:41 -0400

To: Sean Whitton, notmuch@notmuchmail.org

Cc:

From: David Bremner


Sean Whitton <spwhitton@spwhitton.name> writes:

> Hello,
>
> In the following situation:
>
> - only notmuch config is ~/.notmuch-config
> - database.mail_root is set
> - database.path is not set
> - notmuch database does not yet exist
>
> then notmuch wants to create its db under mail_root/.notmuch, contrary
> to notmuch-config(1).
>

Thanks for the report. It looks like the case database.mail_root being
set when database.path is not set is not as well tested as it should
be. I have updated T055-path-config.sh to remedy this [1]. Most things
seem to work, but database creating (and upgrading) seem broken.

[1]:

diff --git a/test/T055-path-config.sh b/test/T055-path-config.sh
index 63dd90fd..7bd3f219 100755
--- a/test/T055-path-config.sh
+++ b/test/T055-path-config.sh
@@ -92,7 +92,19 @@ xdg_config () {
     notmuch --config=${CONFIG_PATH} config set database.path
 }
 
-for config in traditional split XDG XDG+profile symlink home_mail maildir_env; do
+mailroot_only_config () {
+    local dir
+
+    backup_config
+    notmuch config set database.mail_root ${TMP_DIRECTORY}/mail
+    notmuch --config=${CONFIG_PATH} config set database.path
+    DATABASE_PATH="${HOME}/.local/share/notmuch/default"
+    rm -rf $DATABASE_PATH
+    mkdir -p $DATABASE_PATH
+    XAPIAN_PATH="${DATABASE_PATH}/xapian"
+}
+
+for config in traditional split XDG XDG+profile symlink home_mail maildir_env mailroot_only; do
     #start each set of tests with an known set of messages
     add_email_corpus
 
@@ -122,6 +134,9 @@ for config in traditional split XDG XDG+profile symlink home_mail maildir_env; d
 	maildir_env)
 	    maildir_env_config
 	    ;;
+	mailroot_only)
+	    mailroot_only_config
+	    ;;
     esac
 
     test_begin_subtest "count ($config)"
@@ -224,6 +239,9 @@ EOF
     test_expect_equal_file_nonempty EXPECTED OUTPUT
 
     test_begin_subtest "upgrade backup ($config)"
+    if [[ $config = mailroot_only ]]; then
+	test_subtest_known_broken
+    fi
     features=$(xapian-metadata get $XAPIAN_PATH features | grep -v "^relative directory paths")
     xapian-metadata set $XAPIAN_PATH features "$features"
     output=$(notmuch new | grep Welcome)
@@ -232,6 +250,9 @@ EOF
 	"Welcome to a new version of notmuch! Your database will now be upgraded."
 
     test_begin_subtest "notmuch +config -database suggests notmuch new ($config)"
+    if [[ $config = mailroot_only ]]; then
+	test_subtest_known_broken
+    fi
     mv "$XAPIAN_PATH" "${XAPIAN_PATH}.bak"
     notmuch > OUTPUT
 cat <<EOF > EXPECTED
@@ -313,6 +334,15 @@ user.other_email
 user.primary_email
 EOF
    test_expect_equal_file EXPECTED OUTPUT
+
+   test_begin_subtest "create database ($config)"
+   if [[ $config = mailroot_only ]]; then
+       test_subtest_known_broken
+   fi
+   rm -r ${XAPIAN_PATH}
+   notmuch new
+   test_expect_equal "$(xapian-metadata get ${XAPIAN_PATH} version)" 3
+
    case $config in
        XDG*)
 	   test_begin_subtest "Set shadowed config value in database ($config)"
@@ -359,9 +389,6 @@ EOF
 	   ;;
    esac
 
-   case $config in
-       split|XDG*)
-   esac
    restore_config
    rm -rf home/.local
    rm -rf home/.config


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

Thread: