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 ms0.migadu.com with LMTPS id iDEiOLodx2E/7wAAgWs5BA (envelope-from ) for ; Sat, 25 Dec 2021 14:33:46 +0100 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 wNTDM7odx2GMdAAA1q6Kng (envelope-from ) for ; Sat, 25 Dec 2021 13:33:46 +0000 Received: from mail.notmuchmail.org (yantan.tethera.net [135.181.149.255]) (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 847F823D1D for ; Sat, 25 Dec 2021 14:33:46 +0100 (CET) Received: from yantan.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 146375F72C; Sat, 25 Dec 2021 13:33:35 +0000 (UTC) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by mail.notmuchmail.org (Postfix) with ESMTP id 3CD585F721 for ; Sat, 25 Dec 2021 13:33:31 +0000 (UTC) Received: by fethera.tethera.net (Postfix, from userid 1001) id 9DF0A5FC42; Sat, 25 Dec 2021 08:33:30 -0500 (EST) Received: (nullmailer pid 3014292 invoked by uid 1000); Sat, 25 Dec 2021 13:33:27 -0000 From: David Bremner To: David Bremner , notmuch@notmuchmail.org Subject: [PATCH 4/6] lib/open: use notmuch->params to track split status Date: Sat, 25 Dec 2021 09:33:03 -0400 Message-Id: <20211225133305.3014272-2-david@tethera.net> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20211225133305.3014272-1-david@tethera.net> References: <20211211124912.1823559-2-david@tethera.net> <20211225133305.3014272-1-david@tethera.net> MIME-Version: 1.0 Message-ID-Hash: HZZUIFOVYKUAAREWLEIYCMSRUTKJ7KW7 X-Message-ID-Hash: HZZUIFOVYKUAAREWLEIYCMSRUTKJ7KW7 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; digests; suspicious-header X-Mailman-Version: 3.3.3 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_IN X-Migadu-Country: DE ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1640439226; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to: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-owner:list-unsubscribe:list-subscribe:list-post; bh=wl6jPrKe+yYSCz+mQS0Uux2pHLwf/93H+3MVrgM/Pag=; b=twrjisK7AyiHAZYPR3GHa73tqRfbIc6oQvIpBs7w6hNZgS8KevuYZ5ptfzL2s3eV0xVkZ5 GKmvuhQLX+QVSjjgfZ8Dkosk0uUHG1xtJ573hvoa+auN5fmdxt3zomIBe7l3cXwdYXhNI3 gPRj6HO6gVe/FM6McusTseCqGnFhWD794cMps3Ahy188ib2uaHyjawAq4wHsO46PzPbuZJ EI/XwhHFPuqg86U8ipOPL8ZfQBl1OuC9a8fshzRNflC5uwn+ZDrqstsj3M6dPm4fGNqrp+ jDj/iIho8c6bEdEs2BhqgHmUKK5O93MupJHbieXR3C3qIVhAcL2GPvE8tbnCdA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1640439226; a=rsa-sha256; cv=none; b=LNyOiYpWKRlSVYA1DljJfmSYN4+a21U+MxUtiFWGWZqA1l2SWRwq6jibhx9JVuraaYC1do uwl618gEL38aIcZIJasEL8tAVA0YVrxLMTjTsnQYdvL9yuHJw4jq1T3RG1GQMoF6zLODfh LTPiShD/UJwZpt+UgNvBLO0X2euNK1U0EOUXvElouS3TUYJDeiuyuMdmoZub+EQiU6I8Ec xKrE3hgrbRdi7gs75k/CzhFkTdzcOVZlTDbqIW03lz06UVjc46dLb+JMkHvV3xBs9kXaAZ tMhEA2S1Uhz1ZnexS3OBMc4hzdc66UtvgZVumn9Z+kbx79eJhillEnbr0g1/Qg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 135.181.149.255 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Spam-Score: -1.74 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 135.181.149.255 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: 847F823D1D X-Spam-Score: -1.74 X-Migadu-Scanner: scn0.migadu.com X-TUID: RZ9NHoovIGeK Persisting this status will allow us to use the information in other compilation units, in particular when setting configuration defaults. --- lib/database-private.h | 7 ++++++- lib/open.cc | 19 ++++++++----------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/lib/database-private.h b/lib/database-private.h index 8133e364..5db8882f 100644 --- a/lib/database-private.h +++ b/lib/database-private.h @@ -191,12 +191,17 @@ operator& (notmuch_field_flag_t a, notmuch_field_flag_t b) Xapian::QueryParser::FLAG_PURE_NOT) /* - * Which parameters were explicit when the database was opened */ + * explicit and implied parameters to open */ typedef enum { NOTMUCH_PARAM_NONE = 0, + /* database passed explicitely */ NOTMUCH_PARAM_DATABASE = 1 << 0, + /* config file passed explicitely */ NOTMUCH_PARAM_CONFIG = 1 << 1, + /* profile name passed explicitely */ NOTMUCH_PARAM_PROFILE = 1 << 2, + /* split (e.g. XDG) configuration */ + NOTMUCH_PARAM_SPLIT = 1 << 3, } notmuch_open_param_t; /* diff --git a/lib/open.cc b/lib/open.cc index 320b690e..bf1d7ae3 100644 --- a/lib/open.cc +++ b/lib/open.cc @@ -190,7 +190,6 @@ _choose_database_path (notmuch_database_t *notmuch, const char *profile, GKeyFile *key_file, const char **database_path, - bool *split, char **message) { if (! *database_path) { @@ -215,7 +214,7 @@ _choose_database_path (notmuch_database_t *notmuch, if (status) { *database_path = NULL; } else { - *split = true; + notmuch->params |= NOTMUCH_PARAM_SPLIT; } } @@ -513,7 +512,6 @@ notmuch_database_open_with_config (const char *database_path, notmuch_database_t *notmuch = NULL; char *message = NULL; GKeyFile *key_file = NULL; - bool split = false; _notmuch_init (); @@ -530,7 +528,7 @@ notmuch_database_open_with_config (const char *database_path, } if ((status = _choose_database_path (notmuch, profile, key_file, - &database_path, &split, + &database_path, &message))) goto DONE; @@ -610,7 +608,6 @@ notmuch_database_create_with_config (const char *database_path, char *message = NULL; GKeyFile *key_file = NULL; int err; - bool split = false; _notmuch_init (); @@ -627,7 +624,7 @@ notmuch_database_create_with_config (const char *database_path, } if ((status = _choose_database_path (notmuch, profile, key_file, - &database_path, &split, &message))) + &database_path, &message))) goto DONE; status = _db_dir_exists (database_path, &message); @@ -636,18 +633,19 @@ notmuch_database_create_with_config (const char *database_path, _set_database_path (notmuch, database_path); - if (key_file && ! split) { + if (key_file && ! (notmuch->params & NOTMUCH_PARAM_SPLIT)) { char *mail_root = notmuch_canonicalize_file_name ( g_key_file_get_string (key_file, "database", "mail_root", NULL)); char *db_path = notmuch_canonicalize_file_name (database_path); - split = (mail_root && (0 != strcmp (mail_root, db_path))); + if (mail_root && (0 != strcmp (mail_root, db_path))) + notmuch->params |= NOTMUCH_PARAM_SPLIT; free (mail_root); free (db_path); } - if (split) { + if (notmuch->params & NOTMUCH_PARAM_SPLIT) { notmuch_path = database_path; } else { if (! (notmuch_path = talloc_asprintf (notmuch, "%s/%s", database_path, ".notmuch"))) { @@ -809,7 +807,6 @@ notmuch_database_load_config (const char *database_path, notmuch_database_t *notmuch = NULL; char *message = NULL; GKeyFile *key_file = NULL; - bool split = false; _notmuch_init (); @@ -832,7 +829,7 @@ notmuch_database_load_config (const char *database_path, } status = _choose_database_path (notmuch, profile, key_file, - &database_path, &split, &message); + &database_path, &message); switch (status) { case NOTMUCH_STATUS_NO_DATABASE: case NOTMUCH_STATUS_SUCCESS: -- 2.34.1