diff options
| author | David Edmondson <dme@dme.org> | 2018-09-08 12:49:40 +0100 |
|---|---|---|
| committer | David Bremner <david@tethera.net> | 2018-09-08 20:19:24 -0300 |
| commit | 95a9c73c72ff61d5514010a1b9bc11f94cbe988c (patch) | |
| tree | c51b0852f18b287fcddd5a2688dc4d25c994ea0b /notmuch-config.c | |
| parent | 87934c432c4bee9df09f268a3f05933c59c2caf1 (diff) | |
notmuch: Database paths without a leading / are relative to $HOME
If the database path specified in the configuration file does *not*
start with a /, presume that it is relative to $HOME and modify the
path used to open the database accordingly.
Diffstat (limited to 'notmuch-config.c')
| -rw-r--r-- | notmuch-config.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/notmuch-config.c b/notmuch-config.c index e1b16609..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 |
