From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id mPT+D1oNRWC6ZgAA0tVLHw (envelope-from ) for ; Sun, 07 Mar 2021 17:28:58 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id ECDOC1oNRWDYFQAAbx9fmQ (envelope-from ) for ; Sun, 07 Mar 2021 17:28:58 +0000 Received: from mail.notmuchmail.org (nmbug.tethera.net [IPv6:2607:5300:201:3100::1657]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id B84AB24699 for ; Sun, 7 Mar 2021 18:28:57 +0100 (CET) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 501EA28CB4; Sun, 7 Mar 2021 12:28:15 -0500 (EST) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by mail.notmuchmail.org (Postfix) with ESMTP id 7257127C50 for ; Sun, 7 Mar 2021 12:27:52 -0500 (EST) Received: by fethera.tethera.net (Postfix, from userid 1001) id 69BFB5FA96; Sun, 7 Mar 2021 12:27:52 -0500 (EST) Received: (nullmailer pid 1091674 invoked by uid 1000); Sun, 07 Mar 2021 17:27:38 -0000 From: David Bremner To: notmuch@notmuchmail.org Cc: David Bremner Subject: [PATCH 20/22] lib/open: fix hook directory calculation in split configuration Date: Sun, 7 Mar 2021 13:27:32 -0400 Message-Id: <20210307172734.1091264-21-david@tethera.net> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210307172734.1091264-1-david@tethera.net> References: <20210307172734.1091264-1-david@tethera.net> MIME-Version: 1.0 Message-ID-Hash: OSVBFSNXTF4KZXH6AGGB6PYPEB44VTQG X-Message-ID-Hash: OSVBFSNXTF4KZXH6AGGB6PYPEB44VTQG X-MailFrom: bremner@tethera.net X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-notmuch.notmuchmail.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.1 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1615138137; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=D3hNTAWxxfyBflMfhv1dg/RB0K9pSKERFwC2LNCyUks=; b=MgGxbaNoxw7iQdy9qWbsLzw+UxZwkgCQOCcqQ5LOSt4tztwLuFTJu8VzVx8zN12urI10ei 8d8/9YwfHVMuddCehX7C28OAyzrGRruS0yyJdDvVxo66jE+zUKodzMyHFB3CQd7imSAMRT oepKSHPLkYbcr9Gifd1kIfdpAKZEevitkLtr2ZA5hBFZYjjQ8DTHiJN3NJ9XUhGopd5n2T bUKGP/ZMkx9oljaxQfNbIEAzTUcE+84/MX62Q79VXyE7xfG6f7VlvTFjVKE1Dgr9BuVE6T xOHC49vyEfMohJj82o+4d1J2/IdopW/yFyzT810aFsoYaJpjMYMkVBGtb0P6cA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1615138137; a=rsa-sha256; cv=none; b=DjxgdipffyS2iCpnEAUvDNB29tgwxKxHV+Pk8Xfx46Jt0CPG/DmVXYCJt7ijWVvOP2lC5Y ICPeMlB1N8Raf9hJjas/8q5Izd6Owz0MmpUEFBxGJcmr0KxEkC8sm+ZKOeFDiMOXrEM3wC OIP6Whl5hlD+ZJhWY5hJ5mdJXd2tM5gKYLFYzyaOzh4a6CMU3/2X9ceqEGUZzOEn6+Z1XK pBJyy4wsKJcvIyTiaIJMD1Xr0z0In47O0A2CMJT9shmINGXw5phU0ZOn5Vt6vGtF4TLRUA FxEIgbkA4UkwS+zYpxjdvRUFXY+DASalVxvXwsybxkFnV42WbvBWDb7nw6JlBw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 2607:5300:201:3100::1657 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Spam-Score: -0.96 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 2607:5300:201:3100::1657 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: B84AB24699 X-Spam-Score: -0.96 X-Migadu-Scanner: scn0.migadu.com X-TUID: e9bnfaXDnCwj Choose sibling directory of xapian database, as .notmuch may not exist. --- lib/open.cc | 6 ++++-- test/T400-hooks.sh | 9 ++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/open.cc b/lib/open.cc index 08f2f052..3417b89e 100644 --- a/lib/open.cc +++ b/lib/open.cc @@ -1,4 +1,6 @@ #include +#include + #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))); 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}]" -- 2.30.1