X-Git-Url: https://git.notmuchmail.org/git?a=blobdiff_plain;f=notmuch-config.c;h=bf77cc9d43831460c63625a8fcef47a9f6464612;hb=d9800c893289b56dcc966241528643ae83f2ff9a;hp=8fb59f96eb6dc44a632854f3054ad89a907ce622;hpb=0f314c0c99befea599a68bea51d759b4133efef6;p=notmuch diff --git a/notmuch-config.c b/notmuch-config.c index 8fb59f96..bf77cc9d 100644 --- a/notmuch-config.c +++ b/notmuch-config.c @@ -660,7 +660,19 @@ _config_set_list (notmuch_config_t *config, const char * notmuch_config_get_database_path (notmuch_config_t *config) { - return _config_get (config, &config->database_path, "database", "path"); + char *db_path = (char *)_config_get (config, &config->database_path, "database", "path"); + + if (db_path && *db_path != '/') { + /* If the path in the configuration file begins with any + * character other than /, presume that it is relative to + * $HOME and update as appropriate. + */ + char *abs_path = talloc_asprintf (config, "%s/%s", getenv ("HOME"), db_path); + talloc_free (db_path); + db_path = config->database_path = abs_path; + } + + return db_path; } void @@ -808,7 +820,20 @@ _item_split (char *item, char **group, char **key) } #define BUILT_WITH_PREFIX "built_with." -#define QUERY_PREFIX "query." + +static bool +_stored_in_db (const char *item) +{ + const char * db_configs[] = { + "index.decrypt", + }; + if (STRNCMP_LITERAL (item, "query.") == 0) + return true; + for (size_t i = 0; i < ARRAY_SIZE (db_configs); i++) + if (strcmp (item, db_configs[i]) == 0) + return true; + return false; +} static int _print_db_config(notmuch_config_t *config, const char *name) @@ -857,7 +882,7 @@ notmuch_config_command_get (notmuch_config_t *config, char *item) } else if (STRNCMP_LITERAL (item, BUILT_WITH_PREFIX) == 0) { printf ("%s\n", notmuch_built_with (item + strlen (BUILT_WITH_PREFIX)) ? "true" : "false"); - } else if (STRNCMP_LITERAL (item, QUERY_PREFIX) == 0) { + } else if (_stored_in_db (item)) { return _print_db_config (config, item); } else { char **value; @@ -928,7 +953,7 @@ notmuch_config_command_set (notmuch_config_t *config, char *item, int argc, char return 1; } - if (STRNCMP_LITERAL (item, QUERY_PREFIX) == 0) { + if (_stored_in_db (item)) { return _set_db_config (config, item, argc, argv); }