From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id 8IJaD43hQGDkMwAA0tVLHw (envelope-from ) for ; Thu, 04 Mar 2021 13:33:01 +0000 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id 8OwNC43hQGBhBQAAbx9fmQ (envelope-from ) for ; Thu, 04 Mar 2021 13:33:01 +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)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id D0EEF22C12 for ; Thu, 4 Mar 2021 14:33:00 +0100 (CET) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 1085327D4F; Thu, 4 Mar 2021 08:32:10 -0500 (EST) Received: from fethera.tethera.net (fethera.tethera.net [IPv6:2607:5300:60:c5::1]) by mail.notmuchmail.org (Postfix) with ESMTP id 2133C27585 for ; Thu, 4 Mar 2021 08:31:46 -0500 (EST) Received: by fethera.tethera.net (Postfix, from userid 1001) id 180935FA96; Thu, 4 Mar 2021 08:31:46 -0500 (EST) Received: (nullmailer pid 4053559 invoked by uid 1000); Thu, 04 Mar 2021 13:31:28 -0000 From: David Bremner To: notmuch@notmuchmail.org Cc: David Bremner Subject: [PATCH 08/22] lib: remove "path" from notmuch struct Date: Thu, 4 Mar 2021 09:31:11 -0400 Message-Id: <20210304133125.4050229-9-david@tethera.net> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210304133125.4050229-1-david@tethera.net> References: <20210304133125.4050229-1-david@tethera.net> MIME-Version: 1.0 Message-ID-Hash: 4OUZ2GW55EOHX2R2QOGTINK5PLB7QFS2 X-Message-ID-Hash: 4OUZ2GW55EOHX2R2QOGTINK5PLB7QFS2 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=1614864780; 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=dzB1SPR6ECPvZ9ZcJusF54CIkIs+OZWzcbfHYjnIKvA=; b=EY8mfoUCWlns0cYEd9Cn4A3yoBQhfFWCfS7G8ZEC3TdA8digQIx1S9jo5ek7+XMCXOfSel w0VvtI7XmwVUY0JU4Bz+PHJ/e/EoLHtep18fWwuPKmmIgChVD3QdVUXmqsqCCQtobd2U9h hMY4sLK5+VJL2kGbSYAzB0bVT3yZtWUosA7MudjkCvqKOm3BYm2EJfdFfQYVF1oS6uh/g4 UCeuuC6LsM2vfMR8U2yG2GDkd7hjfsFmM4q/iNpWvCkGZWeORAJQ4z+LLIAiQ/UrVXu08I CnAkleAFJyZdV1QhCPC7PKR/w6VmrMGPLes5WWmMki7LmVdh7sMajRdFihq4hg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1614864780; a=rsa-sha256; cv=none; b=LZTEve7t0dJUjGdCqBEvtuuriGkmTKvvEGYQ0Ej5Tf3dg0Edd5YSvYkZ5792G9mtlAfZKu kRDaQ/Y6UyF7x0EOB1TAarC3O4DZHp5o4sFJk0hmu9o9LF5CnzaaRDwslFsb+f1+BmNKz+ Lx7VJo0UEhWXDhEqqvxDlTm1NmURnUQzlY4ao/b+6vBMA+t4sTwGXZMPaBqOCY3pq4ZunT zjI5fUZrLLgG/oSpTBjNYybDFBgeN5UTCM8Hlp0xS5DR7i04q76gYknwxuPyebkuzES7QQ d+BDyaiBmX0PEztNnBMzBcLyRlKyBnzALtmKFcW5W4J+bi7B0ePyALtEKA/lbQ== 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.03 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: D0EEF22C12 X-Spam-Score: -1.03 X-Migadu-Scanner: scn0.migadu.com X-TUID: pElH1HQJemX0 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.1