From: David Bremner Date: Wed, 3 Mar 2021 12:31:44 +0000 (-0400) Subject: lib/open: canonicalize relative path read from config file X-Git-Tag: 0.32_rc0~29 X-Git-Url: https://git.cworth.org/git?p=notmuch;a=commitdiff_plain;h=b25e57e6cb65c31030322125aafb0a5eb085b420;ds=sidebyside 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. --- 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;