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 oAquMzkNRWAzZAAA0tVLHw (envelope-from ) for ; Sun, 07 Mar 2021 17:28:25 +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 2OaELzkNRWDSVgAA1q6Kng (envelope-from ) for ; Sun, 07 Mar 2021 17:28:25 +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 aspmx1.migadu.com (Postfix) with ESMTPS id 698FE1499D for ; Sun, 7 Mar 2021 18:28:25 +0100 (CET) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 821F027D4B; Sun, 7 Mar 2021 12:28:00 -0500 (EST) Received: from fethera.tethera.net (fethera.tethera.net [IPv6:2607:5300:60:c5::1]) by mail.notmuchmail.org (Postfix) with ESMTP id ED8E227BC0 for ; Sun, 7 Mar 2021 12:27:45 -0500 (EST) Received: by fethera.tethera.net (Postfix, from userid 1001) id E6F805FA96; Sun, 7 Mar 2021 12:27:45 -0500 (EST) Received: (nullmailer pid 1091649 invoked by uid 1000); Sun, 07 Mar 2021 17:27:38 -0000 From: David Bremner To: notmuch@notmuchmail.org Cc: David Bremner Subject: [PATCH 08/22] lib: remove "path" from notmuch struct Date: Sun, 7 Mar 2021 13:27:20 -0400 Message-Id: <20210307172734.1091264-9-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: 6KMY4TESJY6BEZQHAXSSPHLRSV6PJCUZ X-Message-ID-Hash: 6KMY4TESJY6BEZQHAXSSPHLRSV6PJCUZ 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=1615138105; 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=6BKAKGbXn6WQ1cUe73bGSur0eWASrmZW5Iuq8sV7EHs=; b=kmhFQSABycCiLr2ZxS/d/RNWNSfoWpZgVcQdredGuNS/RYnlymHu6TaRbG4Zh/UWi95H0F GkuRghHQ0kZ5VKfGeS8hhW+0FY9Khz3WrmG6CWtMcs3uKha0z7UShtshoRArQve9SOoPX0 1ZpOG+RZvr9SugEZ2TAtdZhPvqR/Pb36qZKy0FHbSYgww3D++3JlJIvvazFq5dRHQrVFn7 2otJJ2c/Fmqj9p7g4aMTxjxpMOK9mzYShfbwop40UK1XhwyHR2AAoMGIhVE52iKgUnsPyu ICQWHEhZBD+3zzx9RF8TfnmY1VqH+q4TUFE8twk7rEKEFf4yDs2GuoJPO6XOYg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1615138105; a=rsa-sha256; cv=none; b=YRuH58MAi3QMTjaKleMDYOndExVwGnyx9xkaYHmMzcz/p09+k8hKoZsbmwyBoZ06XBA2Om mBxPXXKUA1WgfK9+xGZTrtgS+6KeCc9ptTTthRBjW+G4KY2SvVaFcur9c2at8zWJumkoJz iW+3PE0Kuz1FBBphOmKIt84tx0l2k/Vmm9OB47Y6QLmDIrYiTMNf/a4UuMPibF7cToC6A7 By44qslT4TzByBHH88zDxdb1uZA5e54gp1hb0776Fy6ugEj/aLMn0mgTWIW9UbsSvqlBEK V1w2cQNZLD1m1V3AugtyZJ4bhlpHsT0DR7o8mCxfEtLOjsTZCUQ9VD8QYH2wEA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=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-Spam-Score: -0.96 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: 698FE1499D X-Spam-Score: -0.96 X-Migadu-Scanner: scn1.migadu.com X-TUID: H8XRr5GQNMBT 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 | 14 ++++++++++++-- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/lib/config.cc b/lib/config.cc index 43c5ddec..64bcf692 100644 --- a/lib/config.cc +++ b/lib/config.cc @@ -494,5 +494,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 7ce07c46..155232f9 100644 --- a/lib/database.cc +++ b/lib/database.cc @@ -750,7 +750,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 21a6b0f4..7d295893 100644 --- a/lib/open.cc +++ b/lib/open.cc @@ -209,6 +209,17 @@ _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, @@ -238,8 +249,7 @@ notmuch_database_open_with_config (const char *database_path, &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.1