4 #include "database-private.h"
5 #include "parse-time-vrp.h"
6 #include "lastmod-fp.h"
9 #if HAVE_XAPIAN_DB_RETRY_LOCK
10 #define DB_ACTION (Xapian::DB_CREATE_OR_OPEN | Xapian::DB_RETRY_LOCK)
12 #define DB_ACTION Xapian::DB_CREATE_OR_OPEN
16 notmuch_database_open (const char *path,
17 notmuch_database_mode_t mode,
18 notmuch_database_t **database)
20 char *status_string = NULL;
21 notmuch_status_t status;
23 status = notmuch_database_open_with_config (path, mode, "", NULL,
24 database, &status_string);
26 fputs (status_string, stderr);
34 notmuch_database_open_verbose (const char *path,
35 notmuch_database_mode_t mode,
36 notmuch_database_t **database,
39 return notmuch_database_open_with_config (path, mode, "", NULL,
40 database, status_string);
45 const char *xdg_root_variable,
46 const char *xdg_prefix,
47 const char *profile_name)
49 const char *xdg_root = getenv (xdg_root_variable);
52 const char *home = getenv ("HOME");
54 if (! home) return NULL;
56 xdg_root = talloc_asprintf (ctx,
63 profile_name = getenv ("NOTMUCH_PROFILE");
66 profile_name = "default";
68 return talloc_asprintf (ctx,
74 static notmuch_status_t
75 _choose_dir (notmuch_database_t *notmuch,
77 notmuch_config_key_t key,
79 const char *xdg_subdir,
81 char **message = NULL)
88 dir = notmuch_config_get (notmuch, key);
91 return NOTMUCH_STATUS_SUCCESS;
93 parent = _xdg_dir (notmuch, xdg_var, xdg_subdir, profile);
95 return NOTMUCH_STATUS_PATH_ERROR;
97 dir = talloc_asprintf (notmuch, "%s/%s", parent, subdir);
99 err = stat (dir, &st);
101 if (errno == ENOENT) {
102 char *notmuch_path = dirname (talloc_strdup (notmuch, notmuch->xapian_path));
103 dir = talloc_asprintf (notmuch, "%s/%s", notmuch_path, subdir);
105 IGNORE_RESULT (asprintf (message, "Error: Cannot stat %s: %s.\n",
106 dir, strerror (errno)));
107 return NOTMUCH_STATUS_FILE_ERROR;
111 _notmuch_config_cache (notmuch, key, dir);
113 return NOTMUCH_STATUS_SUCCESS;
116 static notmuch_status_t
117 _load_key_file (notmuch_database_t *notmuch,
122 notmuch_status_t status = NOTMUCH_STATUS_SUCCESS;
124 if (path && EMPTY_STRING (path))
128 path = getenv ("NOTMUCH_CONFIG");
131 path = talloc_strdup (notmuch, path);
133 const char *dir = _xdg_dir (notmuch, "XDG_CONFIG_HOME", ".config", profile);
136 path = talloc_asprintf (notmuch, "%s/config", dir);
137 if (access (path, R_OK) != 0)
143 const char *home = getenv ("HOME");
145 path = talloc_asprintf (notmuch, "%s/.notmuch-config", home);
148 profile = getenv ("NOTMUCH_PROFILE");
151 path = talloc_asprintf (notmuch, "%s.%s", path, profile);
154 *key_file = g_key_file_new ();
155 if (! g_key_file_load_from_file (*key_file, path, G_KEY_FILE_NONE, NULL)) {
156 status = NOTMUCH_STATUS_NO_CONFIG;
161 notmuch->config_path = path;
166 static notmuch_status_t
167 _db_dir_exists (const char *database_path, char **message)
172 err = stat (database_path, &st);
174 IGNORE_RESULT (asprintf (message, "Error: Cannot open database at %s: %s.\n",
175 database_path, strerror (errno)));
176 return NOTMUCH_STATUS_FILE_ERROR;
179 if (! S_ISDIR (st.st_mode)) {
180 IGNORE_RESULT (asprintf (message, "Error: Cannot open database at %s: "
181 "Not a directory.\n",
183 return NOTMUCH_STATUS_FILE_ERROR;
186 return NOTMUCH_STATUS_SUCCESS;
189 static notmuch_status_t
190 _choose_database_path (notmuch_database_t *notmuch,
193 const char **database_path,
196 notmuch_status_t status;
198 if (! *database_path) {
199 *database_path = getenv ("NOTMUCH_DATABASE");
202 if (! *database_path && key_file) {
203 char *path = g_key_file_get_string (key_file, "database", "path", NULL);
206 *database_path = talloc_strdup (notmuch, path);
208 *database_path = talloc_asprintf (notmuch, "%s/%s", getenv ("HOME"), path);
212 if (! *database_path) {
213 *database_path = _xdg_dir (notmuch, "XDG_DATA_HOME", ".local/share", profile);
214 status = _db_dir_exists (*database_path, message);
216 *database_path = NULL;
218 notmuch->params |= NOTMUCH_PARAM_SPLIT;
222 if (! *database_path) {
223 *database_path = getenv ("MAILDIR");
226 if (! *database_path) {
227 *database_path = talloc_asprintf (notmuch, "%s/mail", getenv ("HOME"));
228 status = _db_dir_exists (*database_path, message);
230 *database_path = NULL;
234 if (*database_path == NULL) {
235 *message = strdup ("Error: could not locate database.\n");
236 return NOTMUCH_STATUS_NO_DATABASE;
239 if (*database_path[0] != '/') {
240 *message = strdup ("Error: Database path must be absolute.\n");
241 return NOTMUCH_STATUS_PATH_ERROR;
244 status = _db_dir_exists (*database_path, message);
246 IGNORE_RESULT (asprintf (message,
247 "Error: database path '%s' does not exist or is not a directory.\n",
249 return NOTMUCH_STATUS_NO_DATABASE;
257 return NOTMUCH_STATUS_SUCCESS;
260 static notmuch_status_t
261 _mkdir (const char *path, char **message)
263 if (g_mkdir_with_parents (path, 0755)) {
264 IGNORE_RESULT (asprintf (message, "Error: Cannot create directory %s: %s.\n",
265 path, strerror (errno)));
266 return NOTMUCH_STATUS_FILE_ERROR;
268 return NOTMUCH_STATUS_SUCCESS;
271 static notmuch_status_t
272 _create_database_path (notmuch_database_t *notmuch,
275 const char **database_path,
278 notmuch_status_t status;
280 if (! *database_path) {
281 *database_path = getenv ("NOTMUCH_DATABASE");
284 if (! *database_path && key_file) {
285 char *path = g_key_file_get_string (key_file, "database", "path", NULL);
288 *database_path = talloc_strdup (notmuch, path);
290 *database_path = talloc_asprintf (notmuch, "%s/%s", getenv ("HOME"), path);
295 if (! *database_path) {
296 *database_path = _xdg_dir (notmuch, "XDG_DATA_HOME", ".local/share", profile);
297 notmuch->params |= NOTMUCH_PARAM_SPLIT;
300 if (*database_path[0] != '/') {
301 *message = strdup ("Error: Database path must be absolute.\n");
302 return NOTMUCH_STATUS_PATH_ERROR;
305 if ((status = _mkdir (*database_path, message)))
308 return NOTMUCH_STATUS_SUCCESS;
311 static notmuch_database_t *
312 _alloc_notmuch (const char *database_path, const char *config_path, const char *profile)
314 notmuch_database_t *notmuch;
316 notmuch = talloc_zero (NULL, notmuch_database_t);
320 notmuch->exception_reported = false;
321 notmuch->status_string = NULL;
322 notmuch->writable_xapian_db = NULL;
323 notmuch->config_path = NULL;
324 notmuch->atomic_nesting = 0;
325 notmuch->transaction_count = 0;
326 notmuch->transaction_threshold = 0;
328 notmuch->index_as_text = NULL;
329 notmuch->index_as_text_length = 0;
331 notmuch->params = NOTMUCH_PARAM_NONE;
333 notmuch->params |= NOTMUCH_PARAM_DATABASE;
335 notmuch->params |= NOTMUCH_PARAM_CONFIG;
337 notmuch->params |= NOTMUCH_PARAM_PROFILE;
342 static notmuch_status_t
343 _trial_open (const char *xapian_path, char **message_ptr)
346 Xapian::Database db (xapian_path);
347 } catch (const Xapian::DatabaseOpeningError &error) {
348 IGNORE_RESULT (asprintf (message_ptr,
349 "Cannot open Xapian database at %s: %s\n",
351 error.get_msg ().c_str ()));
352 return NOTMUCH_STATUS_PATH_ERROR;
353 } catch (const Xapian::Error &error) {
354 IGNORE_RESULT (asprintf (message_ptr,
355 "A Xapian exception occurred opening database: %s\n",
356 error.get_msg ().c_str ()));
357 return NOTMUCH_STATUS_XAPIAN_EXCEPTION;
359 return NOTMUCH_STATUS_SUCCESS;
363 _notmuch_choose_xapian_path (void *ctx, const char *database_path,
364 const char **xapian_path, char **message_ptr)
366 notmuch_status_t status;
367 const char *trial_path, *notmuch_path;
369 status = _db_dir_exists (database_path, message_ptr);
373 trial_path = talloc_asprintf (ctx, "%s/xapian", database_path);
374 status = _trial_open (trial_path, message_ptr);
375 if (status != NOTMUCH_STATUS_PATH_ERROR)
381 notmuch_path = talloc_asprintf (ctx, "%s/.notmuch", database_path);
382 status = _db_dir_exists (notmuch_path, message_ptr);
386 trial_path = talloc_asprintf (ctx, "%s/xapian", notmuch_path);
387 status = _trial_open (trial_path, message_ptr);
390 if (status == NOTMUCH_STATUS_SUCCESS)
391 *xapian_path = trial_path;
396 _set_database_path (notmuch_database_t *notmuch,
397 const char *database_path)
399 char *path = talloc_strdup (notmuch, database_path);
401 strip_trailing (path, '/');
403 _notmuch_config_cache (notmuch, NOTMUCH_CONFIG_DATABASE_PATH, path);
407 _load_database_state (notmuch_database_t *notmuch)
409 std::string last_thread_id;
410 std::string last_mod;
412 notmuch->last_doc_id = notmuch->xapian_db->get_lastdocid ();
413 last_thread_id = notmuch->xapian_db->get_metadata ("last_thread_id");
414 if (last_thread_id.empty ()) {
415 notmuch->last_thread_id = 0;
420 str = last_thread_id.c_str ();
421 notmuch->last_thread_id = strtoull (str, &end, 16);
423 INTERNAL_ERROR ("Malformed database last_thread_id: %s", str);
426 /* Get current highest revision number. */
427 last_mod = notmuch->xapian_db->get_value_upper_bound (
428 NOTMUCH_VALUE_LAST_MOD);
429 if (last_mod.empty ())
430 notmuch->revision = 0;
432 notmuch->revision = Xapian::sortable_unserialise (last_mod);
433 notmuch->uuid = talloc_strdup (
434 notmuch, notmuch->xapian_db->get_uuid ().c_str ());
437 /* XXX This should really be done lazily, but the error reporting path in the indexing code
438 * would need to be redone to report any errors.
441 _ensure_index_as_text (notmuch_database_t *notmuch, char **message)
444 regex_t *regexv = NULL;
446 if (notmuch->index_as_text)
447 return NOTMUCH_STATUS_SUCCESS;
449 for (notmuch_config_values_t *list = notmuch_config_get_values (notmuch,
450 NOTMUCH_CONFIG_INDEX_AS_TEXT);
451 notmuch_config_values_valid (list);
452 notmuch_config_values_move_to_next (list)) {
455 const char *str = notmuch_config_values_get (list);
456 size_t len = strlen (str);
458 /* str must be non-empty, because n_c_get_values skips empty
462 regexv = talloc_realloc (notmuch, regexv, regex_t, nregex + 1);
463 new_regex = ®exv[nregex];
465 rerr = regcomp (new_regex, str, REG_EXTENDED | REG_NOSUB);
467 size_t error_size = regerror (rerr, new_regex, NULL, 0);
468 char *error = (char *) talloc_size (str, error_size);
470 regerror (rerr, new_regex, error, error_size);
471 IGNORE_RESULT (asprintf (message, "Error in index.as_text: %s: %s\n", error, str));
473 return NOTMUCH_STATUS_ILLEGAL_ARGUMENT;
478 notmuch->index_as_text = regexv;
479 notmuch->index_as_text_length = nregex;
481 return NOTMUCH_STATUS_SUCCESS;
484 static notmuch_status_t
485 _finish_open (notmuch_database_t *notmuch,
487 notmuch_database_mode_t mode,
491 notmuch_status_t status = NOTMUCH_STATUS_SUCCESS;
492 char *incompat_features;
493 char *message = NULL;
494 const char *autocommit_str;
495 char *autocommit_end;
496 unsigned int version;
497 const char *database_path = notmuch_database_get_path (notmuch);
501 if (mode == NOTMUCH_DATABASE_MODE_READ_WRITE) {
502 notmuch->writable_xapian_db = new Xapian::WritableDatabase (notmuch->xapian_path,
504 notmuch->xapian_db = notmuch->writable_xapian_db;
506 notmuch->xapian_db = new Xapian::Database (notmuch->xapian_path);
509 /* Check version. As of database version 3, we represent
510 * changes in terms of features, so assume a version bump
511 * means a dramatically incompatible change. */
512 version = notmuch_database_get_version (notmuch);
513 if (version > NOTMUCH_DATABASE_VERSION) {
514 IGNORE_RESULT (asprintf (&message,
515 "Error: Notmuch database at %s\n"
516 " has a newer database format version (%u) than supported by this\n"
517 " version of notmuch (%u).\n",
518 database_path, version, NOTMUCH_DATABASE_VERSION));
519 status = NOTMUCH_STATUS_FILE_ERROR;
523 /* Check features. */
524 incompat_features = NULL;
525 notmuch->features = _notmuch_database_parse_features (
526 notmuch, notmuch->xapian_db->get_metadata ("features").c_str (),
527 version, mode == NOTMUCH_DATABASE_MODE_READ_WRITE ? 'w' : 'r',
529 if (incompat_features) {
530 IGNORE_RESULT (asprintf (&message,
531 "Error: Notmuch database at %s\n"
532 " requires features (%s)\n"
533 " not supported by this version of notmuch.\n",
534 database_path, incompat_features));
535 status = NOTMUCH_STATUS_FILE_ERROR;
539 _load_database_state (notmuch);
541 notmuch->query_parser = new Xapian::QueryParser;
542 notmuch->term_gen = new Xapian::TermGenerator;
543 notmuch->term_gen->set_stemmer (Xapian::Stem ("english"));
544 notmuch->value_range_processor = new Xapian::NumberRangeProcessor (NOTMUCH_VALUE_TIMESTAMP);
545 notmuch->date_range_processor = new ParseTimeRangeProcessor (NOTMUCH_VALUE_TIMESTAMP,
547 notmuch->last_mod_range_processor = new LastModRangeProcessor (notmuch, "lastmod:");
548 notmuch->query_parser->set_default_op (Xapian::Query::OP_AND);
549 notmuch->query_parser->set_database (*notmuch->xapian_db);
550 notmuch->stemmer = new Xapian::Stem ("english");
551 notmuch->query_parser->set_stemmer (*notmuch->stemmer);
552 notmuch->query_parser->set_stemming_strategy (Xapian::QueryParser::STEM_SOME);
553 notmuch->query_parser->add_rangeprocessor (notmuch->value_range_processor);
554 notmuch->query_parser->add_rangeprocessor (notmuch->date_range_processor);
555 notmuch->query_parser->add_rangeprocessor (notmuch->last_mod_range_processor);
557 /* Configuration information is needed to set up query parser */
558 status = _notmuch_config_load_from_database (notmuch);
563 status = _notmuch_config_load_from_file (notmuch, key_file, &message);
567 status = _choose_dir (notmuch, profile,
568 NOTMUCH_CONFIG_HOOK_DIR,
576 status = _choose_dir (notmuch, profile,
577 NOTMUCH_CONFIG_BACKUP_DIR,
584 status = _notmuch_config_load_defaults (notmuch);
588 status = _ensure_index_as_text (notmuch, &message);
592 autocommit_str = notmuch_config_get (notmuch, NOTMUCH_CONFIG_AUTOCOMMIT);
593 if (unlikely (! autocommit_str)) {
594 INTERNAL_ERROR ("missing configuration for autocommit");
596 notmuch->transaction_threshold = strtoul (autocommit_str, &autocommit_end, 10);
597 if (*autocommit_end != '\0')
598 INTERNAL_ERROR ("Malformed database database.autocommit value: %s", autocommit_str);
600 status = _notmuch_database_setup_standard_query_fields (notmuch);
604 status = _notmuch_database_setup_user_query_fields (notmuch);
608 } catch (const Xapian::Error &error) {
609 IGNORE_RESULT (asprintf (&message, "A Xapian exception occurred opening database: %s\n",
610 error.get_msg ().c_str ()));
611 status = NOTMUCH_STATUS_XAPIAN_EXCEPTION;
615 *message_ptr = message;
620 notmuch_database_open_with_config (const char *database_path,
621 notmuch_database_mode_t mode,
622 const char *config_path,
624 notmuch_database_t **database,
625 char **status_string)
627 notmuch_status_t status = NOTMUCH_STATUS_SUCCESS;
628 notmuch_database_t *notmuch = NULL;
629 char *message = NULL;
630 GKeyFile *key_file = NULL;
634 notmuch = _alloc_notmuch (database_path, config_path, profile);
636 status = NOTMUCH_STATUS_OUT_OF_MEMORY;
640 status = _load_key_file (notmuch, config_path, profile, &key_file);
642 message = strdup ("Error: cannot load config file.\n");
646 if ((status = _choose_database_path (notmuch, profile, key_file,
651 status = _db_dir_exists (database_path, &message);
655 _set_database_path (notmuch, database_path);
657 status = _notmuch_choose_xapian_path (notmuch, database_path,
658 ¬much->xapian_path, &message);
662 status = _finish_open (notmuch, profile, mode, key_file, &message);
666 g_key_file_free (key_file);
670 *status_string = message;
675 if (status && notmuch) {
676 notmuch_database_destroy (notmuch);
684 notmuch->open = true;
690 notmuch_database_create (const char *path, notmuch_database_t **database)
692 char *status_string = NULL;
693 notmuch_status_t status;
695 status = notmuch_database_create_verbose (path, database,
699 fputs (status_string, stderr);
700 free (status_string);
707 notmuch_database_create_verbose (const char *path,
708 notmuch_database_t **database,
709 char **status_string)
711 return notmuch_database_create_with_config (path, "", NULL, database, status_string);
715 notmuch_database_create_with_config (const char *database_path,
716 const char *config_path,
718 notmuch_database_t **database,
719 char **status_string)
721 notmuch_status_t status = NOTMUCH_STATUS_SUCCESS;
722 notmuch_database_t *notmuch = NULL;
723 const char *notmuch_path = NULL;
724 char *message = NULL;
725 GKeyFile *key_file = NULL;
729 notmuch = _alloc_notmuch (database_path, config_path, profile);
731 status = NOTMUCH_STATUS_OUT_OF_MEMORY;
735 status = _load_key_file (notmuch, config_path, profile, &key_file);
737 message = strdup ("Error: cannot load config file.\n");
741 status = _choose_database_path (notmuch, profile, key_file,
742 &database_path, &message);
744 case NOTMUCH_STATUS_SUCCESS:
746 case NOTMUCH_STATUS_NO_DATABASE:
747 if ((status = _create_database_path (notmuch, profile, key_file,
748 &database_path, &message)))
755 _set_database_path (notmuch, database_path);
757 if (key_file && ! (notmuch->params & NOTMUCH_PARAM_SPLIT)) {
758 char *mail_root = notmuch_canonicalize_file_name (
759 g_key_file_get_string (key_file, "database", "mail_root", NULL));
760 char *db_path = notmuch_canonicalize_file_name (database_path);
762 if (mail_root && (0 != strcmp (mail_root, db_path)))
763 notmuch->params |= NOTMUCH_PARAM_SPLIT;
769 if (notmuch->params & NOTMUCH_PARAM_SPLIT) {
770 notmuch_path = database_path;
772 if (! (notmuch_path = talloc_asprintf (notmuch, "%s/%s", database_path, ".notmuch"))) {
773 status = NOTMUCH_STATUS_OUT_OF_MEMORY;
777 status = _mkdir (notmuch_path, &message);
782 if (! (notmuch->xapian_path = talloc_asprintf (notmuch, "%s/%s", notmuch_path, "xapian"))) {
783 status = NOTMUCH_STATUS_OUT_OF_MEMORY;
787 status = _trial_open (notmuch->xapian_path, &message);
788 if (status == NOTMUCH_STATUS_SUCCESS) {
789 notmuch_database_destroy (notmuch);
791 status = NOTMUCH_STATUS_DATABASE_EXISTS;
798 status = _finish_open (notmuch,
800 NOTMUCH_DATABASE_MODE_READ_WRITE,
806 /* Upgrade doesn't add these feature to existing databases, but
807 * new databases have them. */
808 notmuch->features |= NOTMUCH_FEATURE_FROM_SUBJECT_ID_VALUES;
809 notmuch->features |= NOTMUCH_FEATURE_INDEXED_MIMETYPES;
810 notmuch->features |= NOTMUCH_FEATURE_UNPREFIX_BODY_ONLY;
812 status = notmuch_database_upgrade (notmuch, NULL, NULL);
814 notmuch_database_close (notmuch);
820 g_key_file_free (key_file);
824 *status_string = message;
828 if (status && notmuch) {
829 notmuch_database_destroy (notmuch);
837 notmuch->open = true;
842 notmuch_database_reopen (notmuch_database_t *notmuch,
843 notmuch_database_mode_t new_mode)
845 notmuch_database_mode_t cur_mode = _notmuch_database_mode (notmuch);
847 if (notmuch->xapian_db == NULL) {
848 _notmuch_database_log (notmuch, "Cannot reopen closed or nonexistent database\n");
849 return NOTMUCH_STATUS_ILLEGAL_ARGUMENT;
853 if (cur_mode == new_mode &&
854 new_mode == NOTMUCH_DATABASE_MODE_READ_ONLY) {
855 notmuch->xapian_db->reopen ();
857 notmuch->xapian_db->close ();
859 delete notmuch->xapian_db;
860 notmuch->xapian_db = NULL;
861 /* no need to free the same object twice */
862 notmuch->writable_xapian_db = NULL;
864 if (new_mode == NOTMUCH_DATABASE_MODE_READ_WRITE) {
865 notmuch->writable_xapian_db = new Xapian::WritableDatabase (notmuch->xapian_path,
867 notmuch->xapian_db = notmuch->writable_xapian_db;
869 notmuch->xapian_db = new Xapian::Database (notmuch->xapian_path,
874 _load_database_state (notmuch);
875 } catch (const Xapian::Error &error) {
876 if (! notmuch->exception_reported) {
877 _notmuch_database_log (notmuch, "Error: A Xapian exception reopening database: %s\n",
878 error.get_msg ().c_str ());
879 notmuch->exception_reported = true;
881 return NOTMUCH_STATUS_XAPIAN_EXCEPTION;
885 notmuch->open = true;
886 return NOTMUCH_STATUS_SUCCESS;
889 static notmuch_status_t
890 _maybe_load_config_from_database (notmuch_database_t *notmuch,
892 const char *database_path,
895 char *message; /* ignored */
897 if (_db_dir_exists (database_path, &message))
898 return NOTMUCH_STATUS_NO_DATABASE;
900 _set_database_path (notmuch, database_path);
902 if (_notmuch_choose_xapian_path (notmuch, database_path, ¬much->xapian_path, &message))
903 return NOTMUCH_STATUS_NO_DATABASE;
905 (void) _finish_open (notmuch, profile, NOTMUCH_DATABASE_MODE_READ_ONLY, key_file, &message);
907 return NOTMUCH_STATUS_SUCCESS;
911 notmuch_database_load_config (const char *database_path,
912 const char *config_path,
914 notmuch_database_t **database,
915 char **status_string)
917 notmuch_status_t status = NOTMUCH_STATUS_SUCCESS, warning = NOTMUCH_STATUS_SUCCESS;
918 notmuch_database_t *notmuch = NULL;
919 char *message = NULL;
920 GKeyFile *key_file = NULL;
924 notmuch = _alloc_notmuch (database_path, config_path, profile);
926 status = NOTMUCH_STATUS_OUT_OF_MEMORY;
930 status = _load_key_file (notmuch, config_path, profile, &key_file);
932 case NOTMUCH_STATUS_SUCCESS:
934 case NOTMUCH_STATUS_NO_CONFIG:
938 message = strdup ("Error: cannot load config file.\n");
942 status = _choose_database_path (notmuch, profile, key_file,
943 &database_path, &message);
945 case NOTMUCH_STATUS_NO_DATABASE:
946 case NOTMUCH_STATUS_SUCCESS:
956 status = _maybe_load_config_from_database (notmuch, key_file, database_path, profile);
958 case NOTMUCH_STATUS_NO_DATABASE:
959 case NOTMUCH_STATUS_SUCCESS:
969 status = _notmuch_config_load_from_file (notmuch, key_file, &message);
973 status = _notmuch_config_load_defaults (notmuch);
979 *status_string = message;
982 status != NOTMUCH_STATUS_NO_DATABASE
983 && status != NOTMUCH_STATUS_NO_CONFIG) {
984 notmuch_database_destroy (notmuch);