unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: David Bremner <david@tethera.net>
To: David Bremner <david@tethera.net>, notmuch@notmuchmail.org
Subject: [PATCH 2/2] lib/open: do not consider .notmuch alone as an existing database.
Date: Sat, 25 Dec 2021 17:22:56 -0400	[thread overview]
Message-ID: <20211225212256.3302545-2-david@tethera.net> (raw)
In-Reply-To: <20211225212256.3302545-1-david@tethera.net>

It makes perfect sense for users to want to pre-create .notmuch,
e.g. to install hooks, so we should handle the case of a .notmuch
directory without an actual xapian database more gracefully.
---
 lib/open.cc              | 8 ++------
 test/T055-path-config.sh | 1 -
 2 files changed, 2 insertions(+), 7 deletions(-)

diff --git a/lib/open.cc b/lib/open.cc
index a91d22ef..54510eac 100644
--- a/lib/open.cc
+++ b/lib/open.cc
@@ -661,16 +661,12 @@ notmuch_database_create_with_config (const char *database_path,
 
 	err = mkdir (notmuch_path, 0755);
 	if (err) {
-	    if (errno == EEXIST) {
-		status = NOTMUCH_STATUS_DATABASE_EXISTS;
-		talloc_free (notmuch);
-		notmuch = NULL;
-	    } else {
+	    if (errno != EEXIST) {
 		IGNORE_RESULT (asprintf (&message, "Error: Cannot create directory %s: %s.\n",
 					 notmuch_path, strerror (errno)));
 		status = NOTMUCH_STATUS_FILE_ERROR;
+		goto DONE;
 	    }
-	    goto DONE;
 	}
     }
 
diff --git a/test/T055-path-config.sh b/test/T055-path-config.sh
index 374aea3b..1df240dd 100755
--- a/test/T055-path-config.sh
+++ b/test/T055-path-config.sh
@@ -322,7 +322,6 @@ EOF
        *)
 	   backup_database
 	   test_begin_subtest ".notmuch without xapian/ handled gracefully ($config)"
-	   test_subtest_known_broken
 	   rm -r $XAPIAN_PATH
 	   test_expect_success "notmuch new"
 	   restore_database
-- 
2.34.1

  reply	other threads:[~2021-12-25 21:23 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-14 12:47 [bug] handle .notmuch without xapian/ more gracefully David Bremner
2021-12-25 21:22 ` [PATCH 1/2] test/new: add known broken test for missing xapian directory David Bremner
2021-12-25 21:22   ` David Bremner [this message]
2021-12-29 17:48     ` [PATCH 2/2] lib/open: do not consider .notmuch alone as an existing database Tomi Ollila
2021-12-29 18:27       ` David Bremner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211225212256.3302545-2-david@tethera.net \
    --to=david@tethera.net \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).