unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* v2 flexible database location
@ 2021-02-17 20:10 David Bremner
  2021-02-17 20:10 ` [PATCH 01/21] lib: publish API for notmuch_database_reopen David Bremner
                   ` (21 more replies)
  0 siblings, 22 replies; 24+ messages in thread
From: David Bremner @ 2021-02-17 20:10 UTC (permalink / raw)
  To: notmuch

This is series 2 of 3 revamping configuration. It obsoletes [1].


The first 4 patches are really unfinished business from the the first
series already merged to master.  They bring merged configuration (no
more "Defined in Database") to notmuch-show (leaving only
notmuch-config and notmuch-setup to be updated).

[PATCH 01/21] lib: publish API for notmuch_database_reopen
[PATCH 02/21] lib: save path of xapian database in notmuch struct.
[PATCH 03/21] lib: support reopening databases for write access.
[PATCH 04/21] CLI/show: complete conversion to new configuration

The next 8 patches also form a logical unit, since they provide (with some
manual moving of files around) support for reading and updating
databases in locations other than the mail root.

[PATCH 05/21] lib/open: support NOTMUCH_DATABASE environment variable
[PATCH 06/21] lib/open: allocate notmuch_t struct early
[PATCH 07/21] lib: remove "path" from notmuch struct
[PATCH 08/21] lib/open: factor out library initialization
[PATCH 09/21] lib/open: reuse directory checks from n_d_c_with_config
[PATCH 10/21] lib/open: factor out the second half of
[PATCH 11/21] lib/open: use _finish_open in n_d_create_with_config
[PATCH 12/21] lib/open: Use check for existing database by trial
[PATCH 13/21] support splitting mail from database location.

The 14 and 16 provide XDG location support for the database


Finally some of the CLI commands need updating, particularly those
that create databases or add messages.


A (lightly edited) diff from the previous version follows

diff --git a/doc/man1/notmuch-config.rst b/doc/man1/notmuch-config.rst
index ec8c10d5..99030a41 100644
--- a/doc/man1/notmuch-config.rst
+++ b/doc/man1/notmuch-config.rst
@@ -56,7 +56,7 @@ The available configuration items are described below.
     History: this configuration value was introduced in notmuch 0.32.
 
     Default: For compatibility with older configurations, the value of
-    database.path is used if database.mail\_root is unset..
+    database.path is used if database.mail\_root is unset.
 
 **database.hook_dir**
 
diff --git a/lib/config.cc b/lib/config.cc
index 44d546db..32ed6f8f 100644
--- a/lib/config.cc
+++ b/lib/config.cc
@@ -394,6 +394,8 @@ _notmuch_config_key_to_string (notmuch_config_key_t key) {
 	return "database.mail_root";
     case NOTMUCH_CONFIG_HOOK_DIR:
 	return "database.hook_dir";
+    case NOTMUCH_CONFIG_BACKUP_DIR:
+	return "database.backup_dir";
     case NOTMUCH_CONFIG_EXCLUDE_TAGS:
 	return "search.exclude_tags";
     case NOTMUCH_CONFIG_NEW_TAGS:
@@ -436,6 +438,7 @@ _notmuch_config_default (notmuch_database_t *notmuch, notmuch_config_key_t key)
     case NOTMUCH_CONFIG_SYNC_MAILDIR_FLAGS:
 	return "true";
     case NOTMUCH_CONFIG_HOOK_DIR:
+    case NOTMUCH_CONFIG_BACKUP_DIR:
     case NOTMUCH_CONFIG_NEW_IGNORE:
     case NOTMUCH_CONFIG_USER_NAME:
     case NOTMUCH_CONFIG_PRIMARY_EMAIL:
@@ -479,7 +482,7 @@ notmuch_config_set (notmuch_database_t *notmuch, notmuch_config_key_t key, const
 void
 _notmuch_config_cache (notmuch_database_t *notmuch, notmuch_config_key_t key, const char *val) {
     if (notmuch->config == NULL)
-	notmuch->config = _notmuch_string_map_create (notmuch);
+       notmuch->config = _notmuch_string_map_create (notmuch);
 
     _notmuch_string_map_set (notmuch->config, _notmuch_config_key_to_string (key), val);
 }
diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h
index ecad87a6..f871756d 100644
--- a/lib/notmuch-private.h
+++ b/lib/notmuch-private.h
@@ -76,7 +76,7 @@ NOTMUCH_BEGIN_DECLS
 #define NOTMUCH_CLEAR_BIT(valp,  bit) \
     (_NOTMUCH_VALID_BIT (bit) ? (*(valp) &= ~(1ull << (bit))) : *(valp))
 
-#define unused(x) x __attribute__ ((unused))
+#define unused(x) x ## _unused __attribute__ ((unused))
 
 /* Thanks to Andrew Tridgell's (SAMBA's) talloc for this definition of
  * unlikely. The talloc source code comes to us via the GNU LGPL v. 3.
diff --git a/lib/notmuch.h b/lib/notmuch.h
index 8fcd3eed..5e4f1dac 100644
--- a/lib/notmuch.h
+++ b/lib/notmuch.h
@@ -882,6 +882,12 @@ notmuch_database_get_all_tags (notmuch_database_t *db);
 /**
  * Reopen an open notmuch database.
  *
+ * @param [in] db	open notmuch database
+ * @param [in] mode	mode (read only or read-write) for reopened database.
+ *
+ * @retval #NOTMUCH_STATUS_SUCCESS
+ * @retval #NOTMUCH_STATUS_ILLEGAL_ARGUMENT	The passed database was not open.
+ * @retval #NOTMUCH_STATUS_XAPIAN_EXCEPTION	A Xapian exception occured
  */
 notmuch_status_t
 notmuch_database_reopen (notmuch_database_t *db, notmuch_database_mode_t mode);
@@ -2469,6 +2475,7 @@ typedef enum _notmuch_config_key {
     NOTMUCH_CONFIG_DATABASE_PATH = NOTMUCH_CONFIG_FIRST,
     NOTMUCH_CONFIG_MAIL_ROOT,
     NOTMUCH_CONFIG_HOOK_DIR,
+    NOTMUCH_CONFIG_BACKUP_DIR,
     NOTMUCH_CONFIG_EXCLUDE_TAGS,
     NOTMUCH_CONFIG_NEW_TAGS,
     NOTMUCH_CONFIG_NEW_IGNORE,
diff --git a/lib/open.cc b/lib/open.cc
index 2311d4a0..e5ef351e 100644
--- a/lib/open.cc
+++ b/lib/open.cc
@@ -1,4 +1,6 @@
 #include <unistd.h>
+#include <libgen.h>
+
 #include "database-private.h"
 #include "parse-time-vrp.h"
 
@@ -69,39 +71,43 @@ _xdg_dir (void *ctx,
 }
 
 static notmuch_status_t
-_choose_hook_dir (notmuch_database_t *notmuch,
-		  const char *profile,
-		  char **message)
+_choose_dir (notmuch_database_t *notmuch,
+	     const char *profile,
+	     notmuch_config_key_t key,
+	     const char *xdg_var,
+	     const char *xdg_subdir,
+	     const char *subdir,
+	     char **message = NULL)
 {
-    const char *config;
-    const char *hook_dir;
+    const char *parent;
+    const char *dir;
     struct stat st;
     int err;
 
-    hook_dir = notmuch_config_get (notmuch, NOTMUCH_CONFIG_HOOK_DIR);
+    dir = notmuch_config_get (notmuch, key);
 
-    if (hook_dir)
+    if (dir)
 	return NOTMUCH_STATUS_SUCCESS;
 
-    config = _xdg_dir (notmuch, "XDG_CONFIG_HOME", ".config", profile);
-    if (! config)
+    parent = _xdg_dir (notmuch, xdg_var, xdg_subdir, profile);
+    if (! parent)
 	return  NOTMUCH_STATUS_PATH_ERROR;
 
-    hook_dir = talloc_asprintf (notmuch, "%s/hooks", config);
+    dir = talloc_asprintf (notmuch, "%s/%s", parent, subdir);
 
-    err = stat (hook_dir, &st);
+    err = stat (dir, &st);
     if (err) {
 	if (errno == ENOENT) {
-	    const char *database_path = notmuch_database_get_path (notmuch);
-	    hook_dir = talloc_asprintf (notmuch, "%s/.notmuch/hooks", database_path);
+	    char *notmuch_path = dirname (talloc_strdup (notmuch, notmuch->xapian_path));
+            dir = talloc_asprintf (notmuch, "%s/%s", notmuch_path, subdir);
 	} else {
 	    IGNORE_RESULT (asprintf (message, "Error: Cannot stat %s: %s.\n",
-				     hook_dir, strerror (errno)));
+				     dir, strerror (errno)));
 	    return NOTMUCH_STATUS_FILE_ERROR;
 	}
     }
 
-    _notmuch_config_cache (notmuch, NOTMUCH_CONFIG_HOOK_DIR, hook_dir);
+    _notmuch_config_cache (notmuch, key, dir);
 
     return NOTMUCH_STATUS_SUCCESS;
 }
@@ -245,7 +251,7 @@ _trial_open (const char *xapian_path, char **message_ptr)
 	IGNORE_RESULT (asprintf (message_ptr,
 				 "A Xapian exception occurred opening database: %s\n",
 				 error.get_msg ().c_str ()));
-       return NOTMUCH_STATUS_XAPIAN_EXCEPTION;
+	return NOTMUCH_STATUS_XAPIAN_EXCEPTION;
     }
     return NOTMUCH_STATUS_SUCCESS;
 }
@@ -278,6 +284,16 @@ _notmuch_choose_xapian_path (void *ctx, const char *database_path, const char **
     return status;
 }
 
+static void
+_set_database_path (notmuch_database_t *notmuch,
+          const char *database_path) {
+    char *path=talloc_strdup (notmuch, database_path);
+
+    strip_trailing (path, '/');
+
+    _notmuch_config_cache (notmuch, NOTMUCH_CONFIG_DATABASE_PATH, path);
+}
+
 static void _init_libs () {
 
     static int initialized = 0;
@@ -401,10 +417,23 @@ _finish_open (notmuch_database_t *notmuch,
 	if (status)
 	    goto DONE;
 
-	status = _choose_hook_dir (notmuch, profile, &message);
+	status = _choose_dir (notmuch, profile,
+			      NOTMUCH_CONFIG_HOOK_DIR,
+			      "XDG_CONFIG_HOME",
+			      ".config",
+			      "hooks",
+			      &message);
 	if (status)
 	    goto DONE;
 
+	status = _choose_dir (notmuch, profile,
+			      NOTMUCH_CONFIG_BACKUP_DIR,
+			      "XDG_DATA_HOME",
+			      ".local/share",
+			      "backups",
+			      &message);
+        if (status)
+            goto DONE;
 	status = _notmuch_config_load_defaults (notmuch);
 	if (status)
 	    goto DONE;
@@ -430,21 +459,11 @@ _finish_open (notmuch_database_t *notmuch,
     return status;
 }
 
-static void
-_set_database_path (notmuch_database_t *notmuch,
-	   const char *database_path) {
-    char *path=talloc_strdup (notmuch, database_path);
-
-    strip_trailing (path, '/');
-
-    _notmuch_config_cache (notmuch, NOTMUCH_CONFIG_DATABASE_PATH, path);
-}
-
 notmuch_status_t
 notmuch_database_open_with_config (const char *database_path,
 				   notmuch_database_mode_t mode,
 				   const char *config_path,
-				   unused(const char *profile),
+				   const char *profile,
 				   notmuch_database_t **database,
 				   char **status_string)
 {
@@ -542,6 +561,8 @@ notmuch_database_create_with_config (const char *database_path,
     int err;
     bool split = false;
 
+    _init_libs ();
+
     notmuch = _alloc_notmuch ();
     if (! notmuch) {
 	status = NOTMUCH_STATUS_OUT_OF_MEMORY;
@@ -560,9 +581,14 @@ notmuch_database_create_with_config (const char *database_path,
     _set_database_path (notmuch, database_path);
 
     if (key_file && !split) {
-	const char *mail_root = g_key_file_get_value (key_file, "database", "mail_root", NULL);
-	/* XXX compare canonicalized versions */
-	split = (mail_root && (0 != strcmp (mail_root, database_path)));
+	char *mail_root = canonicalize_file_name (
+	    g_key_file_get_value (key_file, "database", "mail_root", NULL));
+	char *db_path = canonicalize_file_name (database_path);
+
+	split = (mail_root && (0 != strcmp (mail_root, db_path)));
+
+	free(mail_root);
+	free (db_path);
     }
 
     if (split) {
@@ -587,11 +613,20 @@ notmuch_database_create_with_config (const char *database_path,
 	    goto DONE;
 	}
     }
+
     if (! (notmuch->xapian_path = talloc_asprintf (notmuch, "%s/%s", notmuch_path, "xapian"))) {
 	status = NOTMUCH_STATUS_OUT_OF_MEMORY;
 	goto DONE;
     }
 
+    status = _trial_open (notmuch->xapian_path, &message);
+    if (status == NOTMUCH_STATUS_SUCCESS) {
+	notmuch_database_destroy (notmuch);
+	notmuch = NULL;
+	status = NOTMUCH_STATUS_DATABASE_EXISTS;
+	goto DONE;
+    }
+
     status = _finish_open (notmuch,
 			   profile,
 			   NOTMUCH_DATABASE_MODE_READ_WRITE,
@@ -633,6 +668,11 @@ notmuch_database_reopen (notmuch_database_t *notmuch,
 			 notmuch_database_mode_t new_mode)
 {
     notmuch_database_mode_t cur_mode = _notmuch_database_mode (notmuch);
+    if (notmuch->xapian_db == NULL) {
+	_notmuch_database_log (notmuch, "Cannot reopen closed or nonexistent database\n");
+	return NOTMUCH_STATUS_ILLEGAL_ARGUMENT;
+    }
+
     try {
 	if (cur_mode == new_mode &&
 	    new_mode == NOTMUCH_DATABASE_MODE_READ_ONLY) {
@@ -664,6 +704,6 @@ notmuch_database_reopen (notmuch_database_t *notmuch,
     }
 
     notmuch->view++;
+    notmuch->open = true;
     return NOTMUCH_STATUS_SUCCESS;
 }
-
diff --git a/notmuch-new.c b/notmuch-new.c
index 63ac10a6..8a8ff69a 100644
--- a/notmuch-new.c
+++ b/notmuch-new.c
@@ -1048,28 +1048,22 @@ _maybe_upgrade (notmuch_database_t *notmuch, add_files_state_t *state) {
     if (notmuch_database_needs_upgrade (notmuch)) {
 	time_t now = time (NULL);
 	struct tm *gm_time = gmtime (&now);
-	struct stat st;
 	int err;
 	notmuch_status_t status;
-	char *dot_notmuch_path = talloc_asprintf (notmuch, "%s/%s", state->db_path, ".notmuch");
-
+	const char *backup_dir = notmuch_config_get (notmuch, NOTMUCH_CONFIG_BACKUP_DIR);
 	const char *backup_name;
 
-	err = stat(dot_notmuch_path, &st);
-	if (err) {
-	    if (errno == ENOENT) {
-		dot_notmuch_path = NULL;
-	    } else {
-		fprintf(stderr, "Failed to stat %s: %s\n", dot_notmuch_path, strerror(errno));
-		return EXIT_FAILURE;
-	    }
+	err = mkdir (backup_dir, 0755);
+	if (err && errno != EEXIST) {
+	    fprintf(stderr, "Failed to create %s: %s\n", backup_dir, strerror(errno));
+	    return EXIT_FAILURE;
 	}
 
 	/* since dump files are written atomically, the amount of
 	 * harm from overwriting one within a second seems
 	 * relatively small. */
 	backup_name = talloc_asprintf (notmuch, "%s/dump-%04d%02d%02dT%02d%02d%02d.gz",
-				       dot_notmuch_path ? dot_notmuch_path : state->db_path,
+				       backup_dir,
 				       gm_time->tm_year + 1900,
 				       gm_time->tm_mon + 1,
 				       gm_time->tm_mday,
diff --git a/test/T055-path-config.sh b/test/T055-path-config.sh
index 44572695..d8828342 100755
--- a/test/T055-path-config.sh
+++ b/test/T055-path-config.sh
@@ -2,6 +2,8 @@
 test_description='Configuration of mail-root and database path'
 . $(dirname "$0")/test-lib.sh || exit 1
 
+test_require_external_prereq xapian-metdata
+
 backup_config () {
     local test_name=$(basename $0 .sh)
     cp ${NOTMUCH_CONFIG} notmuch-config-backup.${test_name}
@@ -13,6 +15,7 @@ restore_config () {
     unset CONFIG_PATH
     unset DATABASE_PATH
     unset NOTMUCH_PROFILE
+    unset XAPIAN_PATH
     cp notmuch-config-backup.${test_name} ${NOTMUCH_CONFIG}
 }
 
@@ -25,6 +28,18 @@ split_config () {
     notmuch config set database.path $dir
     notmuch config set database.mail_root $MAIL_DIR
     DATABASE_PATH=$dir
+    XAPIAN_PATH="$dir/xapian"
+}
+
+symlink_config () {
+    local dir
+    backup_config
+    dir="$TMP_DIRECTORY/link.$test_count"
+    ln -s $MAIL_DIR $dir
+    notmuch config set database.path $dir
+    notmuch config set database.mail_root $MAIL_DIR
+    XAPIAN_PATH="$MAIL_DIR/.notmuch/xapian"
+    unset DATABASE_PATH
 }
 
 xdg_config () {
@@ -46,21 +61,19 @@ xdg_config () {
     mv ${NOTMUCH_CONFIG} $CONFIG_PATH
     unset NOTMUCH_CONFIG
 
+    XAPIAN_PATH="${DATABASE_PATH}/xapian"
     notmuch --config=${CONFIG_PATH} config set database.mail_root ${TMP_DIRECTORY}/mail
     notmuch --config=${CONFIG_PATH} config set database.path
 }
 
-for config in traditional split+prefix split XDG XDG+profile; do
+for config in traditional split XDG XDG+profile symlink; do
     #start each set of tests with an known set of messages
     add_email_corpus
 
     case $config in
 	traditional)
 	    backup_config
-	    ;;
-	split+prefix)
-	    split_config
-	    mv mail/.notmuch $DATABASE_PATH
+	    XAPIAN_PATH="$MAIL_DIR/.notmuch/xapian"
 	    ;;
 	split)
 	    split_config
@@ -74,6 +87,9 @@ for config in traditional split+prefix split XDG XDG+profile; do
 	    xdg_config ${RANDOM}
 	    mv mail/.notmuch/xapian $DATABASE_PATH
 	    ;;
+	symlink)
+	    symlink_config
+	    ;;
     esac
 
     test_begin_subtest "count ($config)"
@@ -87,6 +103,40 @@ for config in traditional split+prefix split XDG XDG+profile; do
     notmuch tag -$tag '*'
     test_expect_equal "$output" '52'
 
+    test_begin_subtest "address ($config)"
+    notmuch address --deduplicate=no --sort=newest-first --output=sender --output=recipients path:foo >OUTPUT
+    cat <<EOF >EXPECTED
+Carl Worth <cworth@cworth.org>
+notmuch@notmuchmail.org
+EOF
+    test_expect_equal_file EXPECTED OUTPUT
+
+    test_begin_subtest "dump ($config)"
+    notmuch dump is:attachment and is:signed | sort > OUTPUT
+    cat <<EOF > EXPECTED
+#notmuch-dump batch-tag:3 config,properties,tags
++attachment +inbox +signed +unread -- id:20091118005829.GB25380@dottiness.seas.harvard.edu
++attachment +inbox +signed +unread -- id:20091118010116.GC25380@dottiness.seas.harvard.edu
+EOF
+    test_expect_equal_file EXPECTED OUTPUT
+
+    test_begin_subtest "dump + tag + restore ($config)"
+    notmuch dump '*' > EXPECTED
+    notmuch tag -inbox '*'
+    notmuch restore < EXPECTED
+    notmuch dump > OUTPUT
+    test_expect_equal_file EXPECTED OUTPUT
+
+    test_begin_subtest "reindex ($config)"
+    notmuch search --output=messages '*' > EXPECTED
+    notmuch reindex '*'
+    notmuch search --output=messages '*' > OUTPUT
+    test_expect_equal_file EXPECTED OUTPUT
+
+    test_begin_subtest "use existing database ($config)"
+    output=$(notmuch new)
+    test_expect_equal "$output" 'No new mail.'
+
     test_begin_subtest "create database ($config)"
     rm -rf $DATABASE_PATH/{.notmuch,}/xapian
     notmuch new
@@ -100,29 +150,12 @@ for config in traditional split+prefix split XDG XDG+profile; do
     output=$(notmuch count '*')
     test_expect_equal "$output" '54'
 
-    test_begin_subtest "insert+search ($config)"
-    generate_message \
-	"[subject]=\"insert-subject\"" \
-	"[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" \
-	"[body]=\"insert-message\""
-    mkdir -p "$MAIL_DIR"/{cur,new,tmp}
-    notmuch insert < "$gen_msg_filename"
-    cur_msg_filename=$(notmuch search --output=files "subject:insert-subject")
-    test_expect_equal_file "$cur_msg_filename" "$gen_msg_filename"
-
     test_begin_subtest "Show a raw message ($config)"
     add_message
     notmuch show --format=raw id:$gen_msg_id > OUTPUT
     test_expect_equal_file $gen_msg_filename OUTPUT
     rm -f $gen_msg_filename
 
-    test_begin_subtest "compact+search ($config)"
-    notmuch search --output=messages '*' | sort > EXPECTED
-    notmuch compact
-    notmuch search --output=messages '*' | sort > OUTPUT
-    test_expect_equal_file EXPECTED OUTPUT
-
-
     test_begin_subtest "reply ($config)"
     add_message '[from]="Sender <sender@example.com>"' \
 		[to]=test_suite@notmuchmail.org \
@@ -141,36 +174,30 @@ On Tue, 05 Jan 2010 15:43:56 -0000, Sender <sender@example.com> wrote:
 > basic reply test
 EOF
     test_expect_equal_file EXPECTED OUTPUT
+    test_begin_subtest "insert+search ($config)"
+    generate_message \
+	"[subject]=\"insert-subject\"" \
+	"[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" \
+	"[body]=\"insert-message\""
+    mkdir -p "$MAIL_DIR"/{cur,new,tmp}
+    notmuch insert < "$gen_msg_filename"
+    cur_msg_filename=$(notmuch search --output=files "subject:insert-subject")
+    test_expect_equal_file "$cur_msg_filename" "$gen_msg_filename"
 
-    test_begin_subtest "address ($config)"
-    notmuch address --deduplicate=no --sort=newest-first --output=sender --output=recipients path:foo >OUTPUT
-    cat <<EOF >EXPECTED
-Carl Worth <cworth@cworth.org>
-notmuch@notmuchmail.org
-EOF
-    test_expect_equal_file EXPECTED OUTPUT
-
-    test_begin_subtest "dump ($config)"
-    notmuch dump is:attachment and is:signed > OUTPUT
-    cat <<EOF > EXPECTED
-#notmuch-dump batch-tag:3 config,properties,tags
-+attachment +inbox +signed +unread -- id:20091118005829.GB25380@dottiness.seas.harvard.edu
-+attachment +inbox +signed +unread -- id:20091118010116.GC25380@dottiness.seas.harvard.edu
-EOF
-    test_expect_equal_file EXPECTED OUTPUT
 
-    test_begin_subtest "dump + tag + restore ($config)"
-    notmuch dump '*' > EXPECTED
-    notmuch tag -inbox '*'
-    notmuch restore < EXPECTED
-    notmuch dump > OUTPUT
+    test_begin_subtest "compact+search ($config)"
+    notmuch search --output=messages '*' | sort > EXPECTED
+    notmuch compact
+    notmuch search --output=messages '*' | sort > OUTPUT
     test_expect_equal_file EXPECTED OUTPUT
 
-    test_begin_subtest 'reindex ($config)'
-    notmuch search --output=messages '*' > EXPECTED
-    notmuch reindex '*'
-    notmuch search --output=messages '*' > OUTPUT
-    test_expect_equal_file EXPECTED OUTPUT
+    test_begin_subtest "upgrade backup ($config)"
+    features=$(xapian-metadata get $XAPIAN_PATH features | grep -v "^relative directory paths")
+    xapian-metadata set $XAPIAN_PATH features "$features"
+    output=$(notmuch new | grep Welcome)
+    test_expect_equal \
+	"$output" \
+	"Welcome to a new version of notmuch! Your database will now be upgraded."
 
     restore_config
 done
diff --git a/test/T400-hooks.sh b/test/T400-hooks.sh
index a3dd4c63..8267d057 100755
--- a/test/T400-hooks.sh
+++ b/test/T400-hooks.sh
@@ -28,9 +28,10 @@ add_message
 # create maildir structure for notmuch-insert
 mkdir -p "$MAIL_DIR"/{cur,new,tmp}
 
-for config in traditional profile explicit XDG; do
+for config in traditional profile explicit XDG split; do
     unset NOTMUCH_PROFILE
     notmuch config set database.hook_dir
+    notmuch config set database.path ${MAIL_DIR}
     case $config in
 	traditional)
 	    HOOK_DIR=${MAIL_DIR}/.notmuch/hooks
@@ -50,6 +51,12 @@ for config in traditional profile explicit XDG; do
 	XDG)
 	    HOOK_DIR=${HOME}/.config/notmuch/default/hooks
 	    ;;
+	split)
+	    dir="$TMP_DIRECTORY/database.$test_count"
+	    notmuch config set database.path $dir
+	    notmuch config set database.mail_root $MAIL_DIR
+	    HOOK_DIR=${dir}/hooks
+	    ;;
     esac
 
     test_begin_subtest "pre-new is run [${config}]"
diff --git a/test/T530-upgrade.sh b/test/T530-upgrade.sh
index c599dacf..cce29f45 100755
--- a/test/T530-upgrade.sh
+++ b/test/T530-upgrade.sh
@@ -5,7 +5,7 @@ test_description='database upgrades'
 test_require_external_prereq xapian-metadata
 
 XAPIAN_PATH=$MAIL_DIR/.notmuch/xapian
-BACKUP_PATH=$MAIL_DIR/.notmuch
+BACKUP_PATH=$MAIL_DIR/.notmuch/backups
 
 delete_feature () {
     local key=$1
diff --git a/test/T590-libconfig.sh b/test/T590-libconfig.sh
index c21c139b..310668a9 100755
--- a/test/T590-libconfig.sh
+++ b/test/T590-libconfig.sh
@@ -366,6 +366,7 @@ cat <<'EOF' >EXPECTED
 MAIL_DIR
 MAIL_DIR
 MAIL_DIR/.notmuch/hooks
+MAIL_DIR/.notmuch/backups
 
 inbox;unread
 NULL
diff --git a/test/json_check_nodes.py b/test/json_check_nodes.py
index 17403c57..fd8f1607 100755
--- a/test/json_check_nodes.py
+++ b/test/json_check_nodes.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 import re
 import sys
 import json

^ permalink raw reply related	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2021-03-07 17:51 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-17 20:10 v2 flexible database location David Bremner
2021-02-17 20:10 ` [PATCH 01/21] lib: publish API for notmuch_database_reopen David Bremner
2021-02-17 20:10 ` [PATCH 02/21] lib: save path of xapian database in notmuch struct David Bremner
2021-02-17 20:10 ` [PATCH 03/21] lib: support reopening databases for write access David Bremner
2021-02-17 20:10 ` [PATCH 04/21] CLI/show: complete conversion to new configuration framework David Bremner
2021-02-17 20:10 ` [PATCH 05/21] lib/open: support NOTMUCH_DATABASE environment variable David Bremner
2021-02-17 20:10 ` [PATCH 06/21] lib/open: allocate notmuch_t struct early David Bremner
2021-02-17 20:10 ` [PATCH 07/21] lib: remove "path" from notmuch struct David Bremner
2021-02-17 20:10 ` [PATCH 08/21] lib/open: factor out library initialization David Bremner
2021-02-17 20:10 ` [PATCH 09/21] lib/open: reuse directory checks from n_d_c_with_config David Bremner
2021-02-17 20:10 ` [PATCH 10/21] lib/open: factor out the second half of n_d_open_with_config David Bremner
2021-02-17 20:10 ` [PATCH 11/21] lib/open: use _finish_open in n_d_create_with_config David Bremner
2021-02-17 20:10 ` [PATCH 12/21] lib/open: Use check for existing database by trial opening David Bremner
2021-02-17 20:10 ` [PATCH 13/21] support splitting mail from database location David Bremner
2021-02-17 20:10 ` [PATCH 14/21] lib/open: check for split configuration when creating database David Bremner
2021-02-17 20:10 ` [PATCH 15/21] CLI/new: support split database and mail location David Bremner
2021-02-17 20:10 ` [PATCH 16/21] lib/open: support XDG_DATA_HOME as a fallback database location David Bremner
2021-02-17 20:10 ` [PATCH 17/21] CLI/insert: support split database and mail root David Bremner
2021-02-17 20:10 ` [PATCH 18/21] lib/compact: enable split config David Bremner
2021-02-17 20:10 ` [PATCH 19/21] lib/open: fix hook directory calculation in split configuration David Bremner
2021-02-17 20:10 ` [PATCH 20/21] lib/config: add configuration variable for backup directory David Bremner
2021-02-17 20:10 ` [PATCH 21/21] CLI/new: use " David Bremner
2021-03-06 18:40 ` Notmuch and backups Matt Armstrong
2021-03-07 17:51   ` David Bremner

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).