From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id EPi1HoN4LWDRGgAA0tVLHw (envelope-from ) for ; Wed, 17 Feb 2021 20:11:47 +0000 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id QBGKGoN4LWBUKgAA1q6Kng (envelope-from ) for ; Wed, 17 Feb 2021 20:11:47 +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 04DC3213A9 for ; Wed, 17 Feb 2021 21:11:47 +0100 (CET) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 1377A26B99; Wed, 17 Feb 2021 15:11:16 -0500 (EST) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by mail.notmuchmail.org (Postfix) with ESMTP id C97AA26A10 for ; Wed, 17 Feb 2021 15:10:57 -0500 (EST) Received: by fethera.tethera.net (Postfix, from userid 1001) id C4AFA6067D; Wed, 17 Feb 2021 15:10:57 -0500 (EST) Received: (nullmailer pid 2021419 invoked by uid 1000); Wed, 17 Feb 2021 20:10:50 -0000 From: David Bremner To: notmuch@notmuchmail.org Cc: David Bremner Subject: [PATCH 07/21] lib: remove "path" from notmuch struct Date: Wed, 17 Feb 2021 16:10:31 -0400 Message-Id: <20210217201045.2021106-8-david@tethera.net> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210217201045.2021106-1-david@tethera.net> References: <20210217201045.2021106-1-david@tethera.net> MIME-Version: 1.0 Message-ID-Hash: 6UPBGCHAKUJM7BAAD6C6EPTAWXCKETLY X-Message-ID-Hash: 6UPBGCHAKUJM7BAAD6C6EPTAWXCKETLY 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.56 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: 04DC3213A9 X-Spam-Score: 0.56 X-Migadu-Scanner: scn0.migadu.com X-TUID: vfOsOLIXHyeV This removes duplication between the struct element and the configuration string_map entry. --- lib/config.cc | 3 +++ lib/database-private.h | 3 --- lib/database.cc | 2 +- lib/open.cc | 13 +++++++++++-- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/lib/config.cc b/lib/config.cc index 948751bc..99b75e7b 100644 --- a/lib/config.cc +++ b/lib/config.cc @@ -473,5 +473,8 @@ notmuch_config_set (notmuch_database_t *notmuch, notmuch_config_key_t key, const void _notmuch_config_cache (notmuch_database_t *notmuch, notmuch_config_key_t key, const char *val) { + if (notmuch->config == NULL) + notmuch->config = _notmuch_string_map_create (notmuch); + _notmuch_string_map_set (notmuch->config, _notmuch_config_key_to_string (key), val); } diff --git a/lib/database-private.h b/lib/database-private.h index d936b216..2900382d 100644 --- a/lib/database-private.h +++ b/lib/database-private.h @@ -189,9 +189,6 @@ operator& (notmuch_field_flag_t a, notmuch_field_flag_t b) struct _notmuch_database { bool exception_reported; - /* Path to database parent directory and or/mail root */ - char *path; - /* Path to actual database */ const char *xapian_path; diff --git a/lib/database.cc b/lib/database.cc index b231a619..afa8b754 100644 --- a/lib/database.cc +++ b/lib/database.cc @@ -748,7 +748,7 @@ notmuch_database_destroy (notmuch_database_t *notmuch) const char * notmuch_database_get_path (notmuch_database_t *notmuch) { - return notmuch->path; + return notmuch_config_get (notmuch, NOTMUCH_CONFIG_DATABASE_PATH); } unsigned int diff --git a/lib/open.cc b/lib/open.cc index c7fb6f81..d599aeac 100644 --- a/lib/open.cc +++ b/lib/open.cc @@ -200,6 +200,16 @@ notmuch_database_t * _alloc_notmuch() { return notmuch; } +static void +_set_database_path (notmuch_database_t *notmuch, + const char *database_path) { + char *path=talloc_strdup (notmuch, database_path); + + strip_trailing (path, '/'); + + _notmuch_config_cache (notmuch, NOTMUCH_CONFIG_DATABASE_PATH, path); +} + notmuch_status_t notmuch_database_open_with_config (const char *database_path, notmuch_database_mode_t mode, @@ -228,8 +238,7 @@ notmuch_database_open_with_config (const char *database_path, if ((status = _choose_database_path (config_path, profile, &key_file, &database_path, &message))) goto DONE; - notmuch->path = talloc_strdup (notmuch, database_path); - strip_trailing (notmuch->path, '/'); + _set_database_path (notmuch, database_path); if (! (notmuch_path = talloc_asprintf (local, "%s/%s", database_path, ".notmuch"))) { message = strdup ("Out of memory\n"); -- 2.30.0