- *database_path = _xdg_dir (ctx, "XDG_DATA_HOME", ".local/share", profile);
- *split = true;
+ notmuch_status_t status;
+
+ *database_path = _xdg_dir (notmuch, "XDG_DATA_HOME", ".local/share", profile);
+ status = _db_dir_exists (*database_path, message);
+ if (status) {
+ *database_path = NULL;
+ } else {
+ notmuch->params |= NOTMUCH_PARAM_SPLIT;
+ }
+ }
+
+ if (! *database_path) {
+ *database_path = getenv ("MAILDIR");
+ }
+
+ 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) {
+ *database_path = NULL;
+ }