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 zOcIIL+IIGACDgAA0tVLHw (envelope-from ) for ; Mon, 08 Feb 2021 00:41:35 +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 eHIYG7+IIGDlbQAAbx9fmQ (envelope-from ) for ; Mon, 08 Feb 2021 00:41:35 +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) server-signature RSA-PSS (2048 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 68D5F94029C for ; Mon, 8 Feb 2021 00:41:34 +0000 (UTC) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 1BF051FBFC; Sun, 7 Feb 2021 19:41:22 -0500 (EST) Received: from fethera.tethera.net (fethera.tethera.net [IPv6:2607:5300:60:c5::1]) by mail.notmuchmail.org (Postfix) with ESMTP id EA6D31FBA4 for ; Sun, 7 Feb 2021 19:41:18 -0500 (EST) Received: by fethera.tethera.net (Postfix, from userid 1001) id D24F0606DD; Sun, 7 Feb 2021 19:41:18 -0500 (EST) Received: (nullmailer pid 1193290 invoked by uid 1000); Mon, 08 Feb 2021 00:41:15 -0000 From: David Bremner To: notmuch@notmuchmail.org Cc: David Bremner Subject: [PATCH 19/23] lib/compact: enable split config Date: Sun, 7 Feb 2021 20:41:05 -0400 Message-Id: <20210208004109.1192719-20-david@tethera.net> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210208004109.1192719-1-david@tethera.net> References: <20210208004109.1192719-1-david@tethera.net> MIME-Version: 1.0 Message-ID-Hash: R54FU7TZ37VTGJTCFP7N2LWBGQGVWEFS X-Message-ID-Hash: R54FU7TZ37VTGJTCFP7N2LWBGQGVWEFS 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 X-Migadu-Spam-Score: -0.88 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: 68D5F94029C X-Spam-Score: -0.88 X-Migadu-Scanner: scn1.migadu.com X-TUID: JYhXxzuXPw9U 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 | 4 ++++ lib/open.cc | 6 +++--- test/T055-path-config.sh | 6 ++++++ 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/lib/database.cc b/lib/database.cc index 1d8839a5..ffd42ac4 100644 --- a/lib/database.cc +++ b/lib/database.cc @@ -607,11 +607,12 @@ notmuch_database_compact_db (notmuch_database_t *notmuch, notmuch_compact_status_cb_t status_cb, 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) @@ -625,15 +626,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 731757cc..ecad87a6 100644 --- a/lib/notmuch-private.h +++ b/lib/notmuch-private.h @@ -726,6 +726,10 @@ _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 a577ddca..2311d4a0 100644 --- a/lib/open.cc +++ b/lib/open.cc @@ -250,8 +250,8 @@ _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; @@ -474,7 +474,7 @@ 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 e5036400..7bd9739b 100755 --- a/test/T055-path-config.sh +++ b/test/T055-path-config.sh @@ -116,6 +116,12 @@ for config in traditional split+prefix split XDG XDG+profile; do test_expect_equal_file $gen_msg_filename OUTPUT rm -f $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.0