From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id QK9pKUMNRWAiUwAA0tVLHw (envelope-from ) for ; Sun, 07 Mar 2021 17:28:35 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id KOEmJUMNRWD8YwAAB5/wlQ (envelope-from ) for ; Sun, 07 Mar 2021 17:28: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) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 3F29E23108 for ; Sun, 7 Mar 2021 18:28:35 +0100 (CET) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id D2E8427D6F; Sun, 7 Mar 2021 12:28:04 -0500 (EST) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by mail.notmuchmail.org (Postfix) with ESMTP id 04E7E27C25 for ; Sun, 7 Mar 2021 12:27:47 -0500 (EST) Received: by fethera.tethera.net (Postfix, from userid 1001) id C29655FA96; Sun, 7 Mar 2021 12:27:47 -0500 (EST) Received: (nullmailer pid 1091672 invoked by uid 1000); Sun, 07 Mar 2021 17:27:38 -0000 From: David Bremner To: notmuch@notmuchmail.org Cc: David Bremner Subject: [PATCH 19/22] lib/compact: enable split config Date: Sun, 7 Mar 2021 13:27:31 -0400 Message-Id: <20210307172734.1091264-20-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: 2NSUXVUOJNYNEHB7EM4KYGT4IWAFJAUM X-Message-ID-Hash: 2NSUXVUOJNYNEHB7EM4KYGT4IWAFJAUM 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=1615138115; 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=m1vEe13DeZ0t1jHYBO06EtAw/gf7RMsr7dW49IWqtBY=; b=st8nGvXSjAPF++jzo5FP6WVqxks+LER2Ag0Glo8CgoF1tY+m+pr/FWo/rsTAVoHbbxN4zn nN5AQtxWMIu6PquPKkkHcXMHwIWq7sMJfqrcoS20o5K+TC817J44IWEWTTDlXBxCwZXSh9 GEcLUqtMrsCG2zHcOm6xr/HAYPPepoXUdSAr99Hky0mVx1WSgmHahWRyHd2E+JuvM+tutD sE5k+bTahV+0i9WTIxSM6nsw+TL3XopVLITt7uA+gMuWRkXa+xIAXAGMabNPdx4sWHBQKk YkSuNOcWr3G/NVi+gThPxlOudPSYDbJt/BUGYBZV3+46Z7D2MGx2Hnwh48Kv9Q== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1615138115; a=rsa-sha256; cv=none; b=ihyNd95F4YODAiQ1o/ORz6eN8A1xh2rZAotkf4bV5MjKgKYHPn4Wk9X5kqF57ZsYDYsWTC Pbuq2uxS0psrV+/OXQX+KO8wAhupXYtQQWRbTaeo9t8A+8GoBWc2Umv3mw4eCBfVPh8LRo EGly0eyPibYaA1GR99Nq45LBl6ryPneQ37+EsSYdqYiOgm8Jx2jUJNKao7npT41BwID7SS eIE7ywojnLqTvyA0EiHz7cj7YKB2jtDNZ92MMhRsb9nXVJ/xW3SaKdQWxIpkq02549r33f VfaFBjoHq6V0aAWVtIuXLS40tvSoShImJcALDytHHBLJbOh4PZbDJG9NDTzZFA== 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.08 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: 3F29E23108 X-Spam-Score: -1.08 X-Migadu-Scanner: scn1.migadu.com X-TUID: WCytCj/SdUr/ 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 | 7 ++++--- test/T055-path-config.sh | 7 +++++++ 4 files changed, 19 insertions(+), 12 deletions(-) diff --git a/lib/database.cc b/lib/database.cc index 12ab1af7..491ede5e 100644 --- a/lib/database.cc +++ b/lib/database.cc @@ -609,11 +609,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) @@ -627,15 +628,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 1174c43c..05443d20 100644 --- a/lib/notmuch-private.h +++ b/lib/notmuch-private.h @@ -724,6 +724,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 95c93744..08f2f052 100644 --- a/lib/open.cc +++ b/lib/open.cc @@ -258,8 +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; @@ -486,7 +487,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 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