summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorDavid Bremner <david@tethera.net>2021-03-03 08:31:44 -0400
committerDavid Bremner <david@tethera.net>2021-03-27 09:26:14 -0300
commitb25e57e6cb65c31030322125aafb0a5eb085b420 (patch)
tree736061a78aced3c352783a434acf49e50a458d3f /lib
parent2e9ee47072e161e85d2ac60515d1c922ea881e40 (diff)
lib/open: canonicalize relative path read from config file
This matches functionality in the the CLI function notmuch_config_get_database_path, which was previously used in the CLI code for all calls to open a database.
Diffstat (limited to 'lib')
-rw-r--r--lib/open.cc6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/open.cc b/lib/open.cc
index 6c3ef46f..d0493950 100644
--- a/lib/open.cc
+++ b/lib/open.cc
@@ -196,11 +196,13 @@ _choose_database_path (void *ctx,
if (! *database_path && key_file) {
char *path = g_key_file_get_value (key_file, "database", "path", NULL);
if (path) {
- *database_path = talloc_strdup (ctx, path);
+ if (path[0] == '/')
+ *database_path = talloc_strdup (ctx, path);
+ else
+ *database_path = talloc_asprintf (ctx, "%s/%s", getenv ("HOME"), path);
g_free (path);
}
}
-
if (! *database_path) {
*database_path = _xdg_dir (ctx, "XDG_DATA_HOME", ".local/share", profile);
*split = true;