From: David Bremner <david@tethera.net>
To: David Bremner <david@tethera.net>, notmuch@notmuchmail.org
Subject: [PATCH 6/6] lib/open: no default mail root in split configurations
Date: Sat, 25 Dec 2021 09:33:05 -0400 [thread overview]
Message-ID: <20211225133305.3014272-4-david@tethera.net> (raw)
In-Reply-To: <20211225133305.3014272-1-david@tethera.net>
If we know the configuration is split, but there is no mail root
defined, this indicates a (lack of) configuration error. Currently
this can only arise in XDG configurations.
---
bindings/python-cffi/notmuch2/_build.py | 1 +
lib/config.cc | 6 +++++-
lib/database.cc | 2 ++
lib/notmuch.h | 4 ++++
test/T590-libconfig.sh | 1 -
5 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/bindings/python-cffi/notmuch2/_build.py b/bindings/python-cffi/notmuch2/_build.py
index 45eb20c0..a55b484f 100644
--- a/bindings/python-cffi/notmuch2/_build.py
+++ b/bindings/python-cffi/notmuch2/_build.py
@@ -54,6 +54,7 @@ ffibuilder.cdef(
NOTMUCH_STATUS_NO_DATABASE,
NOTMUCH_STATUS_DATABASE_EXISTS,
NOTMUCH_STATUS_BAD_QUERY_SYNTAX,
+ NOTMUCH_STATUS_NO_MAIL_ROOT,
NOTMUCH_STATUS_LAST_STATUS
} notmuch_status_t;
typedef enum {
diff --git a/lib/config.cc b/lib/config.cc
index 8f6ef110..f61eb636 100644
--- a/lib/config.cc
+++ b/lib/config.cc
@@ -657,6 +657,7 @@ notmuch_status_t
_notmuch_config_load_defaults (notmuch_database_t *notmuch)
{
notmuch_config_key_t key;
+ notmuch_status_t status = NOTMUCH_STATUS_SUCCESS;
if (notmuch->config == NULL)
notmuch->config = _notmuch_string_map_create (notmuch);
@@ -669,11 +670,14 @@ _notmuch_config_load_defaults (notmuch_database_t *notmuch)
val = _notmuch_string_map_get (notmuch->config, key_string);
if (! val) {
+ if (key == NOTMUCH_CONFIG_MAIL_ROOT && (notmuch->params & NOTMUCH_PARAM_SPLIT))
+ status = NOTMUCH_STATUS_NO_MAIL_ROOT;
+
_notmuch_string_map_set (notmuch->config, key_string, _notmuch_config_default (notmuch,
key));
}
}
- return NOTMUCH_STATUS_SUCCESS;
+ return status;
}
const char *
diff --git a/lib/database.cc b/lib/database.cc
index 6ef56d56..0effe978 100644
--- a/lib/database.cc
+++ b/lib/database.cc
@@ -311,6 +311,8 @@ notmuch_status_to_string (notmuch_status_t status)
return "Database exists, not recreated";
case NOTMUCH_STATUS_BAD_QUERY_SYNTAX:
return "Syntax error in query";
+ case NOTMUCH_STATUS_NO_MAIL_ROOT:
+ return "No mail root found";
default:
case NOTMUCH_STATUS_LAST_STATUS:
return "Unknown error status value";
diff --git a/lib/notmuch.h b/lib/notmuch.h
index 1b2bdf3f..fef98b4b 100644
--- a/lib/notmuch.h
+++ b/lib/notmuch.h
@@ -224,6 +224,10 @@ typedef enum {
* Syntax error in query
*/
NOTMUCH_STATUS_BAD_QUERY_SYNTAX,
+ /**
+ * No mail root could be deduced from parameters and environment
+ */
+ NOTMUCH_STATUS_NO_MAIL_ROOT,
/**
* Not an actual status value. Just a way to find out how many
* valid status values there are.
diff --git a/test/T590-libconfig.sh b/test/T590-libconfig.sh
index 9cc79e8c..0b5291ab 100755
--- a/test/T590-libconfig.sh
+++ b/test/T590-libconfig.sh
@@ -1022,7 +1022,6 @@ notmuch_dir_sanitize < OUTPUT > OUTPUT.clean
test_expect_equal_file EXPECTED.common OUTPUT.clean
test_begin_subtest "open/error: config=empty with no mail root in db (xdg)"
-test_subtest_known_broken
old_NOTMUCH_CONFIG=${NOTMUCH_CONFIG}
unset NOTMUCH_CONFIG
backup_database
--
2.34.1
next prev parent reply other threads:[~2021-12-25 13:33 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-11 12:49 [PATCH 1/2] test/libconfig: save and restore config file David Bremner
2021-12-11 12:49 ` [PATCH 2/2] test/libconfig: add two tests for the config = "" case David Bremner
2021-12-25 13:33 ` [PATCH 3/6] lib/open: use db struct as talloc ctx for choose_database_path David Bremner
2021-12-25 13:33 ` [PATCH 4/6] lib/open: use notmuch->params to track split status David Bremner
2021-12-25 13:33 ` [PATCH 5/6] lib/config: make sure the config map exists when loading defaults David Bremner
2021-12-25 13:33 ` David Bremner [this message]
2022-01-16 1:56 ` [PATCH 1/2] test/libconfig: save and restore config file David Bremner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211225133305.3014272-4-david@tethera.net \
--to=david@tethera.net \
--cc=notmuch@notmuchmail.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).