From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id sAqOL4jhQGD/LgAA0tVLHw (envelope-from ) for ; Thu, 04 Mar 2021 13:32:56 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id kAuEK4jhQGAHLwAA1q6Kng (envelope-from ) for ; Thu, 04 Mar 2021 13:32:56 +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 585CE16AD5 for ; Thu, 4 Mar 2021 14:32:56 +0100 (CET) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 598E627D4A; Thu, 4 Mar 2021 08:32:08 -0500 (EST) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by mail.notmuchmail.org (Postfix) with ESMTP id 25E412758D for ; Thu, 4 Mar 2021 08:31:45 -0500 (EST) Received: by fethera.tethera.net (Postfix, from userid 1001) id 1E0395FA96; Thu, 4 Mar 2021 08:31:45 -0500 (EST) Received: (nullmailer pid 4053584 invoked by uid 1000); Thu, 04 Mar 2021 13:31:28 -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: Thu, 4 Mar 2021 09:31:23 -0400 Message-Id: <20210304133125.4050229-21-david@tethera.net> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210304133125.4050229-1-david@tethera.net> References: <20210304133125.4050229-1-david@tethera.net> MIME-Version: 1.0 Message-ID-Hash: 4MKLEM2NUVF3HEW3TQ2YGHVITPAEFLDE X-Message-ID-Hash: 4MKLEM2NUVF3HEW3TQ2YGHVITPAEFLDE 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=1614864776; 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=fryMvoDZM0yjW4PW+HWEVC5coLwj2xwAdmmMcXl5C5Y=; b=TJkLvJZkMfC2Ziab7PUccf52Lu7ifAeDL9A8tTSyOL+7CVEnK0ychx77Y8W0x/a3Z65c33 Ugn88ATGYZtfQgM+nyDWKdbCqrUHK8eotdxalGI9OxCGvrh+Mvvi6GdtsAHSIrp5elyaEW Qn+KzWDJ2vqF9vFvnlffFYIVnBsKxp43fDWyseYVgOLrri4+NDm7lWCGcxZ7KxTUdccr83 A3x0/vwsi95g7bsadv9jcXnbRmkPnFmBUj2j4vyuMWTXuW5hqr6g7bnT0nkzaLcJQHbY9V ottoTd6ndlfj3DtHAwYcCOSoFel4J5wvQ5k/Ven0w1EwwnJe9cyrlPXPwENRmg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1614864776; a=rsa-sha256; cv=none; b=Frw6GevjdO7xoAB9BdJOOfLtNdD8jYV7IzQV3EeSBlSmYw4axCYWAdlwcaWP2IkkhGaWeP n1RJ1peiaghcOKvY1Cmzr2JUIqI5q1j7pqob4nCqEREN2wDHZjCP0ord/p0tafO7Lh6cTO jU0gg9VsscqvwUy9Ikuzfpj219zi3x6MwX9lmf0YWnDXga3k83doxc6K4IHa0nyDiETs0c sNrTeJxZUAPy1uq8yx4VB67Tj3EYkz4nnls7OkM7CGGIzmBBuE2GSXaKH/yw3XiB9UFusP 7kHgaCktE1/Ntn8Kyou7SbTafD2LVD6v6WRJuUeBAc6EaIIGo21UCPQsT1CEmw== 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.80 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: 585CE16AD5 X-Spam-Score: -0.80 X-Migadu-Scanner: scn1.migadu.com X-TUID: 8ZAHRQm/xOum 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 1e2a62cd..4324deae 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