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;
252 return NOTMUCH_STATUS_SUCCESS;
255 static notmuch_status_t
256 _mkdir (const char *path, char **message)
258 if (g_mkdir_with_parents (path, 0755)) {
259 IGNORE_RESULT (asprintf (message, "Error: Cannot create directory %s: %s.\n",
260 path, strerror (errno)));
261 return NOTMUCH_STATUS_FILE_ERROR;
263 return NOTMUCH_STATUS_SUCCESS;
266 static notmuch_status_t
267 _create_database_path (notmuch_database_t *notmuch,
270 const char **database_path,
273 notmuch_status_t status;
275 if (! *database_path) {
276 *database_path = getenv ("NOTMUCH_DATABASE");
279 if (! *database_path && key_file) {
280 char *path = g_key_file_get_string (key_file, "database", "path", NULL);
283 *database_path = talloc_strdup (notmuch, path);
285 *database_path = talloc_asprintf (notmuch, "%s/%s", getenv ("HOME"), path);
290 if (! *database_path) {
291 *database_path = _xdg_dir (notmuch, "XDG_DATA_HOME", ".local/share", profile);
292 notmuch->params |= NOTMUCH_PARAM_SPLIT;
295 if (*database_path[0] != '/') {
296 *message = strdup ("Error: Database path must be absolute.\n");
297 return NOTMUCH_STATUS_PATH_ERROR;
300 if ((status = _mkdir (*database_path, message)))
303 return NOTMUCH_STATUS_SUCCESS;
306 static notmuch_database_t *
307 _alloc_notmuch (const char *database_path, const char *config_path, const char *profile)
309 notmuch_database_t *notmuch;
311 notmuch = talloc_zero (NULL, notmuch_database_t);
315 notmuch->exception_reported = false;
316 notmuch->status_string = NULL;
317 notmuch->writable_xapian_db = NULL;
318 notmuch->config_path = NULL;
319 notmuch->atomic_nesting = 0;
320 notmuch->transaction_count = 0;
321 notmuch->transaction_threshold = 0;
323 notmuch->index_as_text = NULL;
324 notmuch->index_as_text_length = 0;
326 notmuch->params = NOTMUCH_PARAM_NONE;
328 notmuch->params |= NOTMUCH_PARAM_DATABASE;
330 notmuch->params |= NOTMUCH_PARAM_CONFIG;
332 notmuch->params |= NOTMUCH_PARAM_PROFILE;
337 static notmuch_status_t
338 _trial_open (const char *xapian_path, char **message_ptr)
341 Xapian::Database db (xapian_path);
342 } catch (const Xapian::DatabaseOpeningError &error) {
343 IGNORE_RESULT (asprintf (message_ptr,
344 "Cannot open Xapian database at %s: %s\n",
346 error.get_msg ().c_str ()));
347 return NOTMUCH_STATUS_PATH_ERROR;
348 } catch (const Xapian::Error &error) {
349 IGNORE_RESULT (asprintf (message_ptr,
350 "A Xapian exception occurred opening database: %s\n",
351 error.get_msg ().c_str ()));
352 return NOTMUCH_STATUS_XAPIAN_EXCEPTION;
354 return NOTMUCH_STATUS_SUCCESS;
358 _notmuch_choose_xapian_path (void *ctx, const char *database_path,
359 const char **xapian_path, char **message_ptr)
361 notmuch_status_t status;
362 const char *trial_path, *notmuch_path;
364 status = _db_dir_exists (database_path, message_ptr);
368 trial_path = talloc_asprintf (ctx, "%s/xapian", database_path);
369 status = _trial_open (trial_path, message_ptr);
370 if (status != NOTMUCH_STATUS_PATH_ERROR)
376 notmuch_path = talloc_asprintf (ctx, "%s/.notmuch", database_path);
377 status = _db_dir_exists (notmuch_path, message_ptr);
381 trial_path = talloc_asprintf (ctx, "%s/xapian", notmuch_path);
382 status = _trial_open (trial_path, message_ptr);
385 if (status == NOTMUCH_STATUS_SUCCESS)
386 *xapian_path = trial_path;
391 _set_database_path (notmuch_database_t *notmuch,
392 const char *database_path)
394 char *path = talloc_strdup (notmuch, database_path);
396 strip_trailing (path, '/');
398 _notmuch_config_cache (notmuch, NOTMUCH_CONFIG_DATABASE_PATH, path);
402 _load_database_state (notmuch_database_t *notmuch)
404 std::string last_thread_id;
405 std::string last_mod;
407 notmuch->last_doc_id = notmuch->xapian_db->get_lastdocid ();
408 last_thread_id = notmuch->xapian_db->get_metadata ("last_thread_id");
409 if (last_thread_id.empty ()) {
410 notmuch->last_thread_id = 0;
415 str = last_thread_id.c_str ();
416 notmuch->last_thread_id = strtoull (str, &end, 16);
418 INTERNAL_ERROR ("Malformed database last_thread_id: %s", str);
421 /* Get current highest revision number. */
422 last_mod = notmuch->xapian_db->get_value_upper_bound (
423 NOTMUCH_VALUE_LAST_MOD);
424 if (last_mod.empty ())
425 notmuch->revision = 0;
427 notmuch->revision = Xapian::sortable_unserialise (last_mod);
428 notmuch->uuid = talloc_strdup (
429 notmuch, notmuch->xapian_db->get_uuid ().c_str ());
432 /* XXX This should really be done lazily, but the error reporting path in the indexing code
433 * would need to be redone to report any errors.
436 _ensure_index_as_text (notmuch_database_t *notmuch, char **message)
439 regex_t *regexv = NULL;
441 if (notmuch->index_as_text)
442 return NOTMUCH_STATUS_SUCCESS;
444 for (notmuch_config_values_t *list = notmuch_config_get_values (notmuch,
445 NOTMUCH_CONFIG_INDEX_AS_TEXT);
446 notmuch_config_values_valid (list);
447 notmuch_config_values_move_to_next (list)) {
450 const char *str = notmuch_config_values_get (list);
451 size_t len = strlen (str);
453 /* str must be non-empty, because n_c_get_values skips empty
457 regexv = talloc_realloc (notmuch, regexv, regex_t, nregex + 1);
458 new_regex = ®exv[nregex];
460 rerr = regcomp (new_regex, str, REG_EXTENDED | REG_NOSUB);
462 size_t error_size = regerror (rerr, new_regex, NULL, 0);
463 char *error = (char *) talloc_size (str, error_size);
465 regerror (rerr, new_regex, error, error_size);
466 IGNORE_RESULT (asprintf (message, "Error in index.as_text: %s: %s\n", error, str));
468 return NOTMUCH_STATUS_ILLEGAL_ARGUMENT;
473 notmuch->index_as_text = regexv;
474 notmuch->index_as_text_length = nregex;
476 return NOTMUCH_STATUS_SUCCESS;
479 static notmuch_status_t
480 _finish_open (notmuch_database_t *notmuch,
482 notmuch_database_mode_t mode,
486 notmuch_status_t status = NOTMUCH_STATUS_SUCCESS;
487 char *incompat_features;
488 char *message = NULL;
489 const char *autocommit_str;
490 char *autocommit_end;
491 unsigned int version;
492 const char *database_path = notmuch_database_get_path (notmuch);
496 if (mode == NOTMUCH_DATABASE_MODE_READ_WRITE) {
497 notmuch->writable_xapian_db = new Xapian::WritableDatabase (notmuch->xapian_path,
499 notmuch->xapian_db = notmuch->writable_xapian_db;
501 notmuch->xapian_db = new Xapian::Database (notmuch->xapian_path);
504 /* Check version. As of database version 3, we represent
505 * changes in terms of features, so assume a version bump
506 * means a dramatically incompatible change. */
507 version = notmuch_database_get_version (notmuch);
508 if (version > NOTMUCH_DATABASE_VERSION) {
509 IGNORE_RESULT (asprintf (&message,
510 "Error: Notmuch database at %s\n"
511 " has a newer database format version (%u) than supported by this\n"
512 " version of notmuch (%u).\n",
513 database_path, version, NOTMUCH_DATABASE_VERSION));
514 status = NOTMUCH_STATUS_FILE_ERROR;
518 /* Check features. */
519 incompat_features = NULL;
520 notmuch->features = _notmuch_database_parse_features (
521 notmuch, notmuch->xapian_db->get_metadata ("features").c_str (),
522 version, mode == NOTMUCH_DATABASE_MODE_READ_WRITE ? 'w' : 'r',
524 if (incompat_features) {
525 IGNORE_RESULT (asprintf (&message,
526 "Error: Notmuch database at %s\n"
527 " requires features (%s)\n"
528 " not supported by this version of notmuch.\n",
529 database_path, incompat_features));
530 status = NOTMUCH_STATUS_FILE_ERROR;
534 _load_database_state (notmuch);
536 notmuch->query_parser = new Xapian::QueryParser;
537 notmuch->term_gen = new Xapian::TermGenerator;
538 notmuch->term_gen->set_stemmer (Xapian::Stem ("english"));
539 notmuch->value_range_processor = new Xapian::NumberRangeProcessor (NOTMUCH_VALUE_TIMESTAMP);
540 notmuch->date_range_processor = new ParseTimeRangeProcessor (NOTMUCH_VALUE_TIMESTAMP,
542 notmuch->last_mod_range_processor = new LastModRangeProcessor (notmuch, "lastmod:");
543 notmuch->query_parser->set_default_op (Xapian::Query::OP_AND);
544 notmuch->query_parser->set_database (*notmuch->xapian_db);
545 notmuch->stemmer = new Xapian::Stem ("english");
546 notmuch->query_parser->set_stemmer (*notmuch->stemmer);
547 notmuch->query_parser->set_stemming_strategy (Xapian::QueryParser::STEM_SOME);
548 notmuch->query_parser->add_rangeprocessor (notmuch->value_range_processor);
549 notmuch->query_parser->add_rangeprocessor (notmuch->date_range_processor);
550 notmuch->query_parser->add_rangeprocessor (notmuch->last_mod_range_processor);
552 /* Configuration information is needed to set up query parser */
553 status = _notmuch_config_load_from_database (notmuch);
558 status = _notmuch_config_load_from_file (notmuch, key_file);
562 status = _choose_dir (notmuch, profile,
563 NOTMUCH_CONFIG_HOOK_DIR,
571 status = _choose_dir (notmuch, profile,
572 NOTMUCH_CONFIG_BACKUP_DIR,
579 status = _notmuch_config_load_defaults (notmuch);
583 status = _ensure_index_as_text (notmuch, &message);
587 autocommit_str = notmuch_config_get (notmuch, NOTMUCH_CONFIG_AUTOCOMMIT);
588 if (unlikely (! autocommit_str)) {
589 INTERNAL_ERROR ("missing configuration for autocommit");
591 notmuch->transaction_threshold = strtoul (autocommit_str, &autocommit_end, 10);
592 if (*autocommit_end != '\0')
593 INTERNAL_ERROR ("Malformed database database.autocommit value: %s", autocommit_str);
595 status = _notmuch_database_setup_standard_query_fields (notmuch);
599 status = _notmuch_database_setup_user_query_fields (notmuch);
603 } catch (const Xapian::Error &error) {
604 IGNORE_RESULT (asprintf (&message, "A Xapian exception occurred opening database: %s\n",
605 error.get_msg ().c_str ()));
606 status = NOTMUCH_STATUS_XAPIAN_EXCEPTION;
610 *message_ptr = message;
615 notmuch_database_open_with_config (const char *database_path,
616 notmuch_database_mode_t mode,
617 const char *config_path,
619 notmuch_database_t **database,
620 char **status_string)
622 notmuch_status_t status = NOTMUCH_STATUS_SUCCESS;
623 notmuch_database_t *notmuch = NULL;
624 char *message = NULL;
625 GKeyFile *key_file = NULL;
629 notmuch = _alloc_notmuch (database_path, config_path, profile);
631 status = NOTMUCH_STATUS_OUT_OF_MEMORY;
635 status = _load_key_file (notmuch, config_path, profile, &key_file);
637 message = strdup ("Error: cannot load config file.\n");
641 if ((status = _choose_database_path (notmuch, profile, key_file,
646 status = _db_dir_exists (database_path, &message);
650 _set_database_path (notmuch, database_path);
652 status = _notmuch_choose_xapian_path (notmuch, database_path,
653 ¬much->xapian_path, &message);
657 status = _finish_open (notmuch, profile, mode, key_file, &message);
661 g_key_file_free (key_file);
665 *status_string = message;
670 if (status && notmuch) {
671 notmuch_database_destroy (notmuch);
679 notmuch->open = true;
685 notmuch_database_create (const char *path, notmuch_database_t **database)
687 char *status_string = NULL;
688 notmuch_status_t status;
690 status = notmuch_database_create_verbose (path, database,
694 fputs (status_string, stderr);
695 free (status_string);
702 notmuch_database_create_verbose (const char *path,
703 notmuch_database_t **database,
704 char **status_string)
706 return notmuch_database_create_with_config (path, "", NULL, database, status_string);
710 notmuch_database_create_with_config (const char *database_path,
711 const char *config_path,
713 notmuch_database_t **database,
714 char **status_string)
716 notmuch_status_t status = NOTMUCH_STATUS_SUCCESS;
717 notmuch_database_t *notmuch = NULL;
718 const char *notmuch_path = NULL;
719 char *message = NULL;
720 GKeyFile *key_file = NULL;
724 notmuch = _alloc_notmuch (database_path, config_path, profile);
726 status = NOTMUCH_STATUS_OUT_OF_MEMORY;
730 status = _load_key_file (notmuch, config_path, profile, &key_file);
732 message = strdup ("Error: cannot load config file.\n");
736 status = _choose_database_path (notmuch, profile, key_file,
737 &database_path, &message);
739 case NOTMUCH_STATUS_SUCCESS:
741 case NOTMUCH_STATUS_NO_DATABASE:
742 if ((status = _create_database_path (notmuch, profile, key_file,
743 &database_path, &message)))
750 _set_database_path (notmuch, database_path);
752 if (key_file && ! (notmuch->params & NOTMUCH_PARAM_SPLIT)) {
753 char *mail_root = notmuch_canonicalize_file_name (
754 g_key_file_get_string (key_file, "database", "mail_root", NULL));
755 char *db_path = notmuch_canonicalize_file_name (database_path);
757 if (mail_root && (0 != strcmp (mail_root, db_path)))
758 notmuch->params |= NOTMUCH_PARAM_SPLIT;
764 if (notmuch->params & NOTMUCH_PARAM_SPLIT) {
765 notmuch_path = database_path;
767 if (! (notmuch_path = talloc_asprintf (notmuch, "%s/%s", database_path, ".notmuch"))) {
768 status = NOTMUCH_STATUS_OUT_OF_MEMORY;
772 status = _mkdir (notmuch_path, &message);
777 if (! (notmuch->xapian_path = talloc_asprintf (notmuch, "%s/%s", notmuch_path, "xapian"))) {
778 status = NOTMUCH_STATUS_OUT_OF_MEMORY;
782 status = _trial_open (notmuch->xapian_path, &message);
783 if (status == NOTMUCH_STATUS_SUCCESS) {
784 notmuch_database_destroy (notmuch);
786 status = NOTMUCH_STATUS_DATABASE_EXISTS;
793 status = _finish_open (notmuch,
795 NOTMUCH_DATABASE_MODE_READ_WRITE,
801 /* Upgrade doesn't add these feature to existing databases, but
802 * new databases have them. */
803 notmuch->features |= NOTMUCH_FEATURE_FROM_SUBJECT_ID_VALUES;
804 notmuch->features |= NOTMUCH_FEATURE_INDEXED_MIMETYPES;
805 notmuch->features |= NOTMUCH_FEATURE_UNPREFIX_BODY_ONLY;
807 status = notmuch_database_upgrade (notmuch, NULL, NULL);
809 notmuch_database_close (notmuch);
815 g_key_file_free (key_file);
819 *status_string = message;
823 if (status && notmuch) {
824 notmuch_database_destroy (notmuch);
832 notmuch->open = true;
837 notmuch_database_reopen (notmuch_database_t *notmuch,
838 notmuch_database_mode_t new_mode)
840 notmuch_database_mode_t cur_mode = _notmuch_database_mode (notmuch);
842 if (notmuch->xapian_db == NULL) {
843 _notmuch_database_log (notmuch, "Cannot reopen closed or nonexistent database\n");
844 return NOTMUCH_STATUS_ILLEGAL_ARGUMENT;
848 if (cur_mode == new_mode &&
849 new_mode == NOTMUCH_DATABASE_MODE_READ_ONLY) {
850 notmuch->xapian_db->reopen ();
852 notmuch->xapian_db->close ();
854 delete notmuch->xapian_db;
855 notmuch->xapian_db = NULL;
856 /* no need to free the same object twice */
857 notmuch->writable_xapian_db = NULL;
859 if (new_mode == NOTMUCH_DATABASE_MODE_READ_WRITE) {
860 notmuch->writable_xapian_db = new Xapian::WritableDatabase (notmuch->xapian_path,
862 notmuch->xapian_db = notmuch->writable_xapian_db;
864 notmuch->xapian_db = new Xapian::Database (notmuch->xapian_path,
869 _load_database_state (notmuch);
870 } catch (const Xapian::Error &error) {
871 if (! notmuch->exception_reported) {
872 _notmuch_database_log (notmuch, "Error: A Xapian exception reopening database: %s\n",
873 error.get_msg ().c_str ());
874 notmuch->exception_reported = true;
876 return NOTMUCH_STATUS_XAPIAN_EXCEPTION;
880 notmuch->open = true;
881 return NOTMUCH_STATUS_SUCCESS;
884 static notmuch_status_t
885 _maybe_load_config_from_database (notmuch_database_t *notmuch,
887 const char *database_path,
890 char *message; /* ignored */
892 if (_db_dir_exists (database_path, &message))
893 return NOTMUCH_STATUS_NO_DATABASE;
895 _set_database_path (notmuch, database_path);
897 if (_notmuch_choose_xapian_path (notmuch, database_path, ¬much->xapian_path, &message))
898 return NOTMUCH_STATUS_NO_DATABASE;
900 (void) _finish_open (notmuch, profile, NOTMUCH_DATABASE_MODE_READ_ONLY, key_file, &message);
902 return NOTMUCH_STATUS_SUCCESS;
906 notmuch_database_load_config (const char *database_path,
907 const char *config_path,
909 notmuch_database_t **database,
910 char **status_string)
912 notmuch_status_t status = NOTMUCH_STATUS_SUCCESS, warning = NOTMUCH_STATUS_SUCCESS;
913 notmuch_database_t *notmuch = NULL;
914 char *message = NULL;
915 GKeyFile *key_file = NULL;
919 notmuch = _alloc_notmuch (database_path, config_path, profile);
921 status = NOTMUCH_STATUS_OUT_OF_MEMORY;
925 status = _load_key_file (notmuch, config_path, profile, &key_file);
927 case NOTMUCH_STATUS_SUCCESS:
929 case NOTMUCH_STATUS_NO_CONFIG:
933 message = strdup ("Error: cannot load config file.\n");
937 status = _choose_database_path (notmuch, profile, key_file,
938 &database_path, &message);
940 case NOTMUCH_STATUS_NO_DATABASE:
941 case NOTMUCH_STATUS_SUCCESS:
951 status = _maybe_load_config_from_database (notmuch, key_file, database_path, profile);
953 case NOTMUCH_STATUS_NO_DATABASE:
954 case NOTMUCH_STATUS_SUCCESS:
964 status = _notmuch_config_load_from_file (notmuch, key_file);
968 status = _notmuch_config_load_defaults (notmuch);
974 *status_string = message;
977 status != NOTMUCH_STATUS_NO_DATABASE
978 && status != NOTMUCH_STATUS_NO_CONFIG) {
979 notmuch_database_destroy (notmuch);