X-Git-Url: https://git.notmuchmail.org/git?a=blobdiff_plain;f=lib%2Fopen.cc;h=ba32c2f16d84d9d19c5bdcf1e5ad58db76d411d7;hb=e7bb7919a2484e12cd5a672eaa21b695b7464acf;hp=77f01f727b6bdae860e4f7c84ce22c6af99e3a91;hpb=74c4ce6d88bcc643424c5d89cc8d30cd835e46c3;p=notmuch diff --git a/lib/open.cc b/lib/open.cc index 77f01f72..ba32c2f1 100644 --- a/lib/open.cc +++ b/lib/open.cc @@ -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;