diff options
| author | David Bremner <david@tethera.net> | 2021-01-03 20:04:46 -0400 |
|---|---|---|
| committer | David Bremner <david@tethera.net> | 2021-03-20 07:43:09 -0300 |
| commit | c82554193d0a0c288ad49e3d4fb8c949b92f71fa (patch) | |
| tree | d917176e6a8aad6baab49f785d4e0ffda9662c0f /lib/open.cc | |
| parent | 2c879667b3c9d51eb23f53c040acce341d75920b (diff) | |
lib/open: support XDG_DATA_HOME as a fallback database location.
This changes some error reporting, either intentionally by reporting
the highest level missing directory, or by side effect from looking in
XDG locations when given null database location.
Diffstat (limited to 'lib/open.cc')
| -rw-r--r-- | lib/open.cc | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/open.cc b/lib/open.cc index 0dfd295f..25691a8a 100644 --- a/lib/open.cc +++ b/lib/open.cc @@ -181,6 +181,7 @@ _choose_database_path (void *ctx, const char *profile, GKeyFile **key_file, const char **database_path, + bool *split, char **message) { notmuch_status_t status; @@ -203,6 +204,11 @@ _choose_database_path (void *ctx, } } + if (! *database_path) { + *database_path = _xdg_dir (ctx, "XDG_DATA_HOME", ".local/share", profile); + *split = true; + } + if (*database_path == NULL) { *message = strdup ("Error: Cannot open a database for a NULL path.\n"); return NOTMUCH_STATUS_NULL_POINTER; @@ -462,6 +468,7 @@ notmuch_database_open_with_config (const char *database_path, notmuch_database_t *notmuch = NULL; char *message = NULL; GKeyFile *key_file = NULL; + bool split = false; _init_libs (); @@ -471,7 +478,8 @@ notmuch_database_open_with_config (const char *database_path, goto DONE; } - if ((status = _choose_database_path (local, config_path, profile, &key_file, &database_path, + if ((status = _choose_database_path (local, config_path, profile, + &key_file, &database_path, &split, &message))) goto DONE; @@ -563,7 +571,8 @@ notmuch_database_create_with_config (const char *database_path, _init_libs (); if ((status = _choose_database_path (local, config_path, profile, - &key_file, &database_path, &message))) + &key_file, &database_path, &split, + &message))) goto DONE; status = _db_dir_exists (database_path, &message); |
