From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id cNDMBpYXTmAKdAAA0tVLHw (envelope-from ) for ; Sun, 14 Mar 2021 14:03:02 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id YAaXApYXTmBsKwAA1q6Kng (envelope-from ) for ; Sun, 14 Mar 2021 14:03:02 +0000 Received: from mail.notmuchmail.org (nmbug.tethera.net [144.217.243.247]) (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 C10CB1CF68 for ; Sun, 14 Mar 2021 15:03:01 +0100 (CET) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 3A02027C45; Sun, 14 Mar 2021 10:02:36 -0400 (EDT) Received: from fethera.tethera.net (fethera.tethera.net [IPv6:2607:5300:60:c5::1]) by mail.notmuchmail.org (Postfix) with ESMTP id EC4BF2757B for ; Sun, 14 Mar 2021 10:02:25 -0400 (EDT) Received: by fethera.tethera.net (Postfix, from userid 1001) id B77EC5FA96; Sun, 14 Mar 2021 10:02:25 -0400 (EDT) Received: (nullmailer pid 183673 invoked by uid 1000); Sun, 14 Mar 2021 14:02:19 -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, 14 Mar 2021 11:02:15 -0300 Message-Id: <20210314140217.183425-21-david@tethera.net> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210314140217.183425-1-david@tethera.net> References: <20210314140217.183425-1-david@tethera.net> MIME-Version: 1.0 Message-ID-Hash: QAZ7O25LNMQKQMIKH7LYLTQV5JMOL2SD X-Message-ID-Hash: QAZ7O25LNMQKQMIKH7LYLTQV5JMOL2SD 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=1615730581; 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=wpayD8eJV4n5zoC8ARm+m8EwEWjtBh00v4m6AU7UewY=; b=uu9sflH5cz5cnPJshA8xVO7D/7wi5zEY3avP/pZ/c5gyYYXOwXvNTibqZRdYmT4x5hWvML teGn0Q2Qp06za13RZ8MPCv5MPJY5Q+1VKiJ5qg1ZtPo4I8biflYJD9Uq15I4siJjVyywwO Q3RbdMAJ3E20eFDvn0zPduOOqa3Xxf8mjkXDnNgz7lX/dk91upT7dlADGr5W3yLb/ahCY3 sv4+vglXeVQtuDnX7xJRO+XPkWCHG9jjhLSja7EuFHDeJfAtkA4PWbBgK9CeyJwtDh98OW aHuwPADScXM0/fSY4++2twjW1BUolVH+7ggw7xhXAMhXjW+JwEDW43aFOHvKCQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1615730581; a=rsa-sha256; cv=none; b=uOKDlqf6lYOwDOD+50AYXhXg4w54+m3XYXqW1iS/99Hb8m4rsbTwmsSJ9aEkqWfKcUvKtu 7pNLzuXMCuC8Wh1p6/0TmLtWe64+R1RO1bLJYvx02GFAN62R3IVpcSLrOCQ1230z/CzcvO ri9VylB0d35V/0r4LxCfE0YmxjAA5rE1repfeNByQ/POLgk7UUUeBqNzIGgbNC1t70lwSb 3aYDhtdUgT5pA+PExhB06QuMLvOx5PJkq19WqYFSJUUudpgheEWKUegBYp9qHQ8F2v04g8 3AuSwXrbXsoOLt0JavYzEZP0UbDeDISyEcNlgQDzkcxPMu9caayr0Dy+SShIPA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 144.217.243.247 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Spam-Score: -1.09 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 144.217.243.247 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: C10CB1CF68 X-Spam-Score: -1.09 X-Migadu-Scanner: scn0.migadu.com X-TUID: JIWbXZCejFtF 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 | 6 ++++-- test/T400-hooks.sh | 9 ++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/open.cc b/lib/open.cc index 8321a3be..aad7fa77 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