]> git.notmuchmail.org Git - notmuch/commitdiff
lib/open: fix hook directory calculation in split configuration
authorDavid Bremner <david@tethera.net>
Wed, 17 Feb 2021 11:16:54 +0000 (07:16 -0400)
committerDavid Bremner <david@tethera.net>
Sat, 20 Mar 2021 10:50:13 +0000 (07:50 -0300)
Choose sibling directory of xapian database, as .notmuch may not
exist.

libgen.h is already used in debugger.c, so it is not a new dependency
/ potential portability problem.

lib/open.cc
test/T400-hooks.sh

index 886c1c90bcd89e575596d0cefb4e13d00b6b30a3..ec0de4c35c1ace550866c2d836cd61e30e50c83c 100644 (file)
@@ -1,4 +1,6 @@
 #include <unistd.h>
+#include <libgen.h>
+
 #include "database-private.h"
 #include "parse-time-vrp.h"
 
@@ -92,8 +94,8 @@ _choose_hook_dir (notmuch_database_t *notmuch,
     err = stat (hook_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));
+           hook_dir = talloc_asprintf (notmuch, "%s/hooks", notmuch_path);
        } else {
            IGNORE_RESULT (asprintf (message, "Error: Cannot stat %s: %s.\n",
                                     hook_dir, strerror (errno)));
index de8e4ba4bfb1c12c459d46cb788637968ac57aeb..3a2df2f4efabe5c7c097a2d6240ac75f80305c7c 100755 (executable)
@@ -43,9 +43,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
@@ -65,6 +66,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}]"