X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=lib%2Fopen.cc;fp=lib%2Fopen.cc;h=bc45055523588d7ff6bf58b381b9b06274704659;hp=85e46dc78dbb16eddcf340e738a236c8d7b517e1;hb=8ba3057d01b11fb806581f8dc451a8891a4d4e0e;hpb=25e2790e303b6d9334676e3165a92c6084aa3567 diff --git a/lib/open.cc b/lib/open.cc index 85e46dc7..bc450555 100644 --- a/lib/open.cc +++ b/lib/open.cc @@ -192,6 +192,8 @@ _choose_database_path (notmuch_database_t *notmuch, const char **database_path, char **message) { + notmuch_status_t status; + if (! *database_path) { *database_path = getenv ("NOTMUCH_DATABASE"); } @@ -207,8 +209,6 @@ _choose_database_path (notmuch_database_t *notmuch, } } if (! *database_path) { - notmuch_status_t status; - *database_path = _xdg_dir (notmuch, "XDG_DATA_HOME", ".local/share", profile); status = _db_dir_exists (*database_path, message); if (status) { @@ -223,8 +223,6 @@ _choose_database_path (notmuch_database_t *notmuch, } if (! *database_path) { - notmuch_status_t status; - *database_path = talloc_asprintf (notmuch, "%s/mail", getenv ("HOME")); status = _db_dir_exists (*database_path, message); if (status) { @@ -241,6 +239,15 @@ _choose_database_path (notmuch_database_t *notmuch, *message = strdup ("Error: Database path must be absolute.\n"); return NOTMUCH_STATUS_PATH_ERROR; } + + status = _db_dir_exists (*database_path, message); + if (status) { + IGNORE_RESULT (asprintf (message, + "Error: database path '%s' does not exist or is not a directory.\n", + *database_path)); + return NOTMUCH_STATUS_NO_DATABASE; + } + return NOTMUCH_STATUS_SUCCESS; } @@ -638,10 +645,6 @@ notmuch_database_create_with_config (const char *database_path, &database_path, &message))) goto DONE; - status = _db_dir_exists (database_path, &message); - if (status) - goto DONE; - _set_database_path (notmuch, database_path); if (key_file && ! (notmuch->params & NOTMUCH_PARAM_SPLIT)) {