]> git.notmuchmail.org Git - notmuch/blobdiff - lib/open.cc
Merge branch 'release'
[notmuch] / lib / open.cc
index 77f01f727b6bdae860e4f7c84ce22c6af99e3a91..ba32c2f16d84d9d19c5bdcf1e5ad58db76d411d7 100644 (file)
@@ -714,10 +714,16 @@ notmuch_database_create_with_config (const char *database_path,
        else
            free (message);
     }
+    if (status && notmuch) {
+       notmuch_database_destroy (notmuch);
+       notmuch = NULL;
+    }
+
     if (database)
        *database = notmuch;
-    else
-       talloc_free (notmuch);
+
+    if (notmuch)
+       notmuch->open = true;
     return status;
 }
 
@@ -865,6 +871,13 @@ notmuch_database_load_config (const char *database_path,
     if (status_string)
        *status_string = message;
 
+    if (status &&
+       status != NOTMUCH_STATUS_NO_DATABASE
+       && status != NOTMUCH_STATUS_NO_CONFIG) {
+       notmuch_database_destroy (notmuch);
+       notmuch = NULL;
+    }
+
     if (database)
        *database = notmuch;