diff options
| author | David Bremner <david@tethera.net> | 2021-02-02 16:43:58 -0400 |
|---|---|---|
| committer | David Bremner <david@tethera.net> | 2021-03-20 07:23:40 -0300 |
| commit | 6251e2bb9ee023d25b58384c8a49576086fdaba3 (patch) | |
| tree | dfec27a8a13bc9f02b9467330cba6361b2a48370 /lib/open.cc | |
| parent | 1383481d4a7cee3b59f354a203090c966a2a635e (diff) | |
lib: remove "path" from notmuch struct
This removes duplication between the struct element and the
configuration string_map entry. Create a simple wrapper for setting
the database path that makes sure the trailing / is stripped.
Diffstat (limited to 'lib/open.cc')
| -rw-r--r-- | lib/open.cc | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/open.cc b/lib/open.cc index 8bd73d6a..7fc9a14f 100644 --- a/lib/open.cc +++ b/lib/open.cc @@ -209,6 +209,17 @@ _alloc_notmuch () return notmuch; } +static void +_set_database_path (notmuch_database_t *notmuch, + const char *database_path) +{ + char *path = talloc_strdup (notmuch, database_path); + + strip_trailing (path, '/'); + + _notmuch_config_cache (notmuch, NOTMUCH_CONFIG_DATABASE_PATH, path); +} + notmuch_status_t notmuch_database_open_with_config (const char *database_path, notmuch_database_mode_t mode, @@ -238,8 +249,7 @@ notmuch_database_open_with_config (const char *database_path, &key_file, &database_path, &message))) goto DONE; - notmuch->path = talloc_strdup (notmuch, database_path); - strip_trailing (notmuch->path, '/'); + _set_database_path (notmuch, database_path); if (! (notmuch_path = talloc_asprintf (local, "%s/%s", database_path, ".notmuch"))) { message = strdup ("Out of memory\n"); |
