]> git.cworth.org Git - notmuch/commitdiff
lib/open: no default mail root in split configurations
authorDavid Bremner <david@tethera.net>
Sat, 25 Dec 2021 13:33:05 +0000 (09:33 -0400)
committerDavid Bremner <david@tethera.net>
Sat, 15 Jan 2022 19:59:39 +0000 (15:59 -0400)
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
lib/config.cc
lib/database.cc
lib/notmuch.h
test/T590-libconfig.sh

index 45eb20c05ee55707f973b532b555853174e28ea1..a55b484fa86030d60e467ffe69f464b192d3e0e2 100644 (file)
@@ -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 {
index 8f6ef110788fe174def7c9014ad6be2cba3eff9c..f61eb63699ce5c0114c18152d54401721efc6c46 100644 (file)
@@ -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 *
index 6ef56d561ca50b42fdad959ad79f24e9e79255e7..0effe97844dba59364ef0fc1d5df74feaa4a135f 100644 (file)
@@ -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";
index 1b2bdf3fa37fda35799cba194e375fd37a44e771..fef98b4bb5f58adba3e3a6610dce66a4e89dda04 100644 (file)
@@ -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.
index 9cc79e8cc449f7d1a991d6982a7aaf78377b8577..0b5291ab4ea1b5d8012ec23533d3b5271b3ce5fe 100755 (executable)
@@ -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