From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:c151::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id QI1BAIoXTmC7DAAA0tVLHw (envelope-from ) for ; Sun, 14 Mar 2021 14:02:50 +0000 Received: from aspmx2.migadu.com ([2001:41d0:2:c151::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id QM2NN4kXTmB+SwAAbx9fmQ (envelope-from ) for ; Sun, 14 Mar 2021 14:02:49 +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) server-digest SHA256) (No client certificate requested) by aspmx2.migadu.com (Postfix) with ESMTPS id 2256D10D5D for ; Sun, 14 Mar 2021 15:02:49 +0100 (CET) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 91F4F27B37; Sun, 14 Mar 2021 10:02:31 -0400 (EDT) Received: from fethera.tethera.net (fethera.tethera.net [IPv6:2607:5300:60:c5::1]) by mail.notmuchmail.org (Postfix) with ESMTP id D04B92705A for ; Sun, 14 Mar 2021 10:02:23 -0400 (EDT) Received: by fethera.tethera.net (Postfix, from userid 1001) id C995E5FA96; Sun, 14 Mar 2021 10:02:23 -0400 (EDT) Received: (nullmailer pid 183671 invoked by uid 1000); Sun, 14 Mar 2021 14:02:19 -0000 From: David Bremner To: notmuch@notmuchmail.org Cc: David Bremner Subject: [PATCH 19/22] lib/compact: enable split config Date: Sun, 14 Mar 2021 11:02:14 -0300 Message-Id: <20210314140217.183425-20-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: T4YZGQS7QCSRMAC3WVW45QTNPIMKPXLB X-Message-ID-Hash: T4YZGQS7QCSRMAC3WVW45QTNPIMKPXLB 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=1615730569; 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=X1Ztls+pBc2ce30s1u3LlKFqZ/9y79W6lVLfSpPqnUc=; b=r8C9pLea1nxWtg7aJ7DqlP/qYDNGOmNmn7cvzLma/8mwWN2nVKaHKtow+85RxXbcEKotSo axO4S5duDoJ/kRGDREyAoqlEHvostgcqwgz18HjwGYMWs/TPX0ockOGMiYgLYRlY4hIH8T R4g5XAtpDhCpeRQCqk0wx3jGUFFrKCWYAyxUo1YXC0e4m3D6x/yClF2BBUA31r1NeWSmJD PD+3MrHvl0n0yGbBgQpFEuzZqhHzix7c8lAiOU7Nzm718e/3BX7NxPsB3FuyN+NxUKxqqc 3DgibWw38rbaimOE3UwYV/mjANhgH/Bo7ovWn8peqoQVY7ZDuUpkM9s0sC7Jvg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1615730569; a=rsa-sha256; cv=none; b=DC+fd+rBJXBH2ysSoQYDWJXvqmVfUQqAfmlWbKUikmqhoCvVZT8IknIT/9g6EZkB3ixmP7 F/aoW7AgvuUBk13akVMgRH6BuyGu5qx2RK6Zc3ELU4c3AW+nc5/TNVGNqt6YsrZgCSp0/C 0SofzRQoZBUEd9mAS0QGu8r0vREedPMApUg254cqf9gdtxgfM/+1NFCxvc+YWg0vk0BvQn FxrxdorhtM6fWWgcGMSTkCJIIyDRXsV8KDADhJ32pj0fKaIdBLzArmR46Q1XasyqtxnFG0 2QE9zibAgpJwgbUwdj2Gg/ZSLZxpTg7xjuzLuHIYPjzRfIwI2k1g7hoAyNOZlQ== ARC-Authentication-Results: i=1; aspmx2.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx2.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: -1.00 Authentication-Results: aspmx2.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx2.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: 2256D10D5D X-Spam-Score: -1.00 X-Migadu-Scanner: scn0.migadu.com X-TUID: zTB36wlC3aR3 This promotes _choose_xapian_path from static to extern linkage in order to share between open.cc and database.cc. --- lib/database.cc | 13 ++++--------- lib/notmuch-private.h | 5 +++++ lib/open.cc | 9 +++++---- test/T055-path-config.sh | 7 +++++++ 4 files changed, 21 insertions(+), 13 deletions(-) diff --git a/lib/database.cc b/lib/database.cc index 248d1dc2..9743c1ca 100644 --- a/lib/database.cc +++ b/lib/database.cc @@ -610,11 +610,12 @@ notmuch_database_compact_db (notmuch_database_t *notmuch, void *closure) { void *local; - char *notmuch_path, *xapian_path, *compact_xapian_path; + const char *xapian_path, *compact_xapian_path; const char *path; notmuch_status_t ret = NOTMUCH_STATUS_SUCCESS; struct stat statbuf; bool keep_backup; + char *message; ret = _notmuch_database_ensure_writable (notmuch); if (ret) @@ -628,15 +629,9 @@ notmuch_database_compact_db (notmuch_database_t *notmuch, if (! local) return NOTMUCH_STATUS_OUT_OF_MEMORY; - if (! (notmuch_path = talloc_asprintf (local, "%s/%s", path, ".notmuch"))) { - ret = NOTMUCH_STATUS_OUT_OF_MEMORY; - goto DONE; - } - - if (! (xapian_path = talloc_asprintf (local, "%s/%s", notmuch_path, "xapian"))) { - ret = NOTMUCH_STATUS_OUT_OF_MEMORY; + ret = _notmuch_choose_xapian_path (local, path, &xapian_path, &message); + if (ret) goto DONE; - } if (! (compact_xapian_path = talloc_asprintf (local, "%s.compact", xapian_path))) { ret = NOTMUCH_STATUS_OUT_OF_MEMORY; diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h index ef814378..387f0c1e 100644 --- a/lib/notmuch-private.h +++ b/lib/notmuch-private.h @@ -724,6 +724,11 @@ _notmuch_config_load_defaults (notmuch_database_t *db); void _notmuch_config_cache (notmuch_database_t *db, notmuch_config_key_t key, const char *val); +/* open.cc */ +notmuch_status_t +_notmuch_choose_xapian_path (void *ctx, const char *database_path, const char **xapian_path, + char **message); + NOTMUCH_END_DECLS #ifdef __cplusplus diff --git a/lib/open.cc b/lib/open.cc index 3097121e..8321a3be 100644 --- a/lib/open.cc +++ b/lib/open.cc @@ -258,9 +258,9 @@ _trial_open (const char *xapian_path, char **message_ptr) return NOTMUCH_STATUS_SUCCESS; } -static notmuch_status_t -_choose_xapian_path (void *ctx, const char *database_path, const char **xapian_path, - char **message_ptr) +notmuch_status_t +_notmuch_choose_xapian_path (void *ctx, const char *database_path, + const char **xapian_path, char **message_ptr) { notmuch_status_t status; const char *trial_path, *notmuch_path; @@ -489,7 +489,8 @@ notmuch_database_open_with_config (const char *database_path, _set_database_path (notmuch, database_path); - status = _choose_xapian_path (local, database_path, ¬much->xapian_path, &message); + status = _notmuch_choose_xapian_path (local, database_path, + ¬much->xapian_path, &message); if (status) goto DONE; diff --git a/test/T055-path-config.sh b/test/T055-path-config.sh index fb5174ac..e4812c82 100755 --- a/test/T055-path-config.sh +++ b/test/T055-path-config.sh @@ -177,6 +177,13 @@ EOF cur_msg_filename=$(notmuch search --output=files "subject:insert-subject") test_expect_equal_file "$cur_msg_filename" "$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 + restore_config done -- 2.30.1