]> git.notmuchmail.org Git - notmuch/blobdiff - lib/config.cc
Merge branch 'release'
[notmuch] / lib / config.cc
index 8775b00af8396280792e4af7049973b873f35586..7a2882dea2360a87ba3bc511c0cdd3c829de20aa 100644 (file)
@@ -259,7 +259,15 @@ _notmuch_config_load_from_database (notmuch_database_t *notmuch)
 
     for (; notmuch_config_list_valid (list); notmuch_config_list_move_to_next (list)) {
        const char *key = notmuch_config_list_key (list);
-       char *normalized_val = _expand_path (list, key, notmuch_config_list_value (list));
+       char *normalized_val = NULL;
+
+       /* If we opened from a given path, do not overwrite it */
+       if (strcmp (key, "database.path") == 0 &&
+           (notmuch->params & NOTMUCH_PARAM_DATABASE) &&
+           notmuch->xapian_db)
+           continue;
+
+       normalized_val = _expand_path (list, key, notmuch_config_list_value (list));
        _notmuch_string_map_append (notmuch->config, key, normalized_val);
        talloc_free (normalized_val);
     }
@@ -427,11 +435,18 @@ _notmuch_config_load_from_file (notmuch_database_t *notmuch,
        for (gchar **keys_p = keys; *keys_p; keys_p++) {
            char *absolute_key = talloc_asprintf (notmuch, "%s.%s", *grp,  *keys_p);
            char *normalized_val;
-           val = g_key_file_get_value (file, *grp, *keys_p, NULL);
+           val = g_key_file_get_string (file, *grp, *keys_p, NULL);
            if (! val) {
                status = NOTMUCH_STATUS_FILE_ERROR;
                goto DONE;
            }
+
+           /* If we opened from a given path, do not overwrite it */
+           if (strcmp (absolute_key, "database.path") == 0 &&
+               (notmuch->params & NOTMUCH_PARAM_DATABASE) &&
+               notmuch->xapian_db)
+               continue;
+
            normalized_val = _expand_path (notmuch, absolute_key, val);
            _notmuch_string_map_set (notmuch->config, absolute_key, normalized_val);
            g_free (val);