}
}
if (! *database_path) {
+ notmuch_status_t status;
+
*database_path = _xdg_dir (ctx, "XDG_DATA_HOME", ".local/share", profile);
- *split = true;
+ status = _db_dir_exists (*database_path, message);
+ if (status) {
+ *database_path = NULL;
+ } else {
+ *split = true;
+ }
+ }
+
+ if (! *database_path) {
+ notmuch_status_t status;
+
+ *database_path = talloc_asprintf (ctx, "%s/mail", getenv ("HOME"));
+ status = _db_dir_exists (*database_path, message);
+ if (status) {
+ *database_path = NULL;
+ }
}
if (*database_path == NULL) {
return NOTMUCH_STATUS_SUCCESS;
}
-notmuch_database_t *
+static notmuch_database_t *
_alloc_notmuch ()
{
notmuch_database_t *notmuch;
_notmuch_config_cache (notmuch, NOTMUCH_CONFIG_DATABASE_PATH, path);
}
-static void
-_init_libs ()
-{
-
- static int initialized = 0;
-
- /* Initialize the GLib type system and threads */
-#if ! GLIB_CHECK_VERSION (2, 35, 1)
- g_type_init ();
-#endif
-
- /* Initialize gmime */
- if (! initialized) {
- g_mime_init ();
- initialized = 1;
- }
-}
-
static void
_load_database_state (notmuch_database_t *notmuch)
{
GKeyFile *key_file = NULL;
bool split = false;
- _init_libs ();
+ _notmuch_init ();
notmuch = _alloc_notmuch ();
if (! notmuch) {
int err;
bool split = false;
- _init_libs ();
+ _notmuch_init ();
notmuch = _alloc_notmuch ();
if (! notmuch) {
return NOTMUCH_STATUS_SUCCESS;
}
-notmuch_status_t
+static notmuch_status_t
_maybe_load_config_from_database (notmuch_database_t *notmuch,
GKeyFile *key_file,
const char *database_path,
GKeyFile *key_file = NULL;
bool split = false;
- _init_libs ();
+ _notmuch_init ();
notmuch = _alloc_notmuch ();
if (! notmuch) {