unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* Database location bug when database does not already exist
@ 2022-07-18 20:26 Sean Whitton
  2022-07-26  1:17 ` David Bremner
  2022-09-03 11:34 ` David Bremner
  0 siblings, 2 replies; 5+ messages in thread
From: Sean Whitton @ 2022-07-18 20:26 UTC (permalink / raw)
  To: notmuch

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).

-- 
Sean Whitton

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Database location bug when database does not already exist
  2022-07-18 20:26 Database location bug when database does not already exist Sean Whitton
@ 2022-07-26  1:17 ` David Bremner
  2022-07-27 12:02   ` David Bremner
  2022-09-03 11:34 ` David Bremner
  1 sibling, 1 reply; 5+ messages in thread
From: David Bremner @ 2022-07-26  1:17 UTC (permalink / raw)
  To: Sean Whitton, notmuch

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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: Database location bug when database does not already exist
  2022-07-26  1:17 ` David Bremner
@ 2022-07-27 12:02   ` David Bremner
  0 siblings, 0 replies; 5+ messages in thread
From: David Bremner @ 2022-07-27 12:02 UTC (permalink / raw)
  To: Sean Whitton, notmuch

David Bremner <david@tethera.net> writes:

> 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.
>

Looking at this a bit more (and fixing a few bugs in those test changes)
I realized the underlying issue is related to what the library
internally callse the "database path" (parent of /xapian) exists. In
particular if .local/share/notmuch/default (or replace default with your
profile name) does not exist, notmuch does not create it. As a
workaround for now you could try creating that directory first.

d

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Database location bug when database does not already exist
  2022-07-18 20:26 Database location bug when database does not already exist Sean Whitton
  2022-07-26  1:17 ` David Bremner
@ 2022-09-03 11:34 ` David Bremner
  2022-09-04  0:58   ` Sean Whitton
  1 sibling, 1 reply; 5+ messages in thread
From: David Bremner @ 2022-09-03 11:34 UTC (permalink / raw)
  To: Sean Whitton, notmuch

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).
>

This bug should be fixed as of commit 84e4e130e2c920b3dee91901582c4ab6276e2630

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Database location bug when database does not already exist
  2022-09-03 11:34 ` David Bremner
@ 2022-09-04  0:58   ` Sean Whitton
  0 siblings, 0 replies; 5+ messages in thread
From: Sean Whitton @ 2022-09-04  0:58 UTC (permalink / raw)
  To: David Bremner, notmuch

Hello,

On Sat 03 Sep 2022 at 08:34AM -03, David Bremner wrote:

> 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).
>>
>
> This bug should be fixed as of commit 84e4e130e2c920b3dee91901582c4ab6276e2630

Nice, thanks!

-- 
Sean Whitton

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-09-04  1:05 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-18 20:26 Database location bug when database does not already exist Sean Whitton
2022-07-26  1:17 ` David Bremner
2022-07-27 12:02   ` David Bremner
2022-09-03 11:34 ` David Bremner
2022-09-04  0:58   ` Sean Whitton

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).