From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id uHHiFhcyH2BDbAAA0tVLHw (envelope-from ) for ; Sun, 07 Feb 2021 00:19:35 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id sPxtEhcyH2C7CwAAbx9fmQ (envelope-from ) for ; Sun, 07 Feb 2021 00:19: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) server-signature RSA-PSS (2048 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id EC8B5940466 for ; Sun, 7 Feb 2021 00:19:34 +0000 (UTC) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id AB3CD1FAE4; Sat, 6 Feb 2021 19:19:18 -0500 (EST) Received: from fethera.tethera.net (fethera.tethera.net [IPv6:2607:5300:60:c5::1]) by mail.notmuchmail.org (Postfix) with ESMTP id 69D801FBB5 for ; Sat, 6 Feb 2021 19:19:14 -0500 (EST) Received: by fethera.tethera.net (Postfix, from userid 1001) id B1B2D606D9; Sat, 6 Feb 2021 19:19:13 -0500 (EST) Received: (nullmailer pid 400381 invoked by uid 1000); Sun, 07 Feb 2021 00:19:11 -0000 From: David Bremner To: David Bremner , notmuch@notmuchmail.org Subject: [PATCH 1/4] lib: publish API for notmuch_database_reopen Date: Sat, 6 Feb 2021 20:19:04 -0400 Message-Id: <20210207001907.400241-2-david@tethera.net> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210207001907.400241-1-david@tethera.net> References: <20210205132654.3258292-40-david@tethera.net> <20210207001907.400241-1-david@tethera.net> MIME-Version: 1.0 Message-ID-Hash: ZIRGH5EOF46ZIB3KXIOMFWCASG7F3TEV X-Message-ID-Hash: ZIRGH5EOF46ZIB3KXIOMFWCASG7F3TEV 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: -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: EC8B5940466 X-Spam-Score: -1.03 X-Migadu-Scanner: scn1.migadu.com X-TUID: 2OiZZpLLMbXO Include the (currently unused) mode argument which will specify which mode to re-open the database in. Functionality and docs to be finalized in a followup commit. --- lib/database.cc | 3 ++- lib/message.cc | 3 ++- lib/notmuch-private.h | 3 --- lib/notmuch.h | 7 +++++++ 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/database.cc b/lib/database.cc index f96ba7c0..89865599 100644 --- a/lib/database.cc +++ b/lib/database.cc @@ -516,7 +516,8 @@ notmuch_database_close (notmuch_database_t *notmuch) } notmuch_status_t -_notmuch_database_reopen (notmuch_database_t *notmuch) +notmuch_database_reopen (notmuch_database_t *notmuch, + unused(notmuch_database_mode_t mode)) { if (_notmuch_database_mode (notmuch) != NOTMUCH_DATABASE_MODE_READ_ONLY) return NOTMUCH_STATUS_UNSUPPORTED_OPERATION; diff --git a/lib/message.cc b/lib/message.cc index fca99082..1bea90f0 100644 --- a/lib/message.cc +++ b/lib/message.cc @@ -455,7 +455,8 @@ _notmuch_message_ensure_metadata (notmuch_message_t *message, void *field) /* all the way without an exception */ break; } catch (const Xapian::DatabaseModifiedError &error) { - notmuch_status_t status = _notmuch_database_reopen (message->notmuch); + notmuch_status_t status = notmuch_database_reopen (message->notmuch, + NOTMUCH_DATABASE_MODE_READ_ONLY); if (status != NOTMUCH_STATUS_SUCCESS) INTERNAL_ERROR ("unhandled error from notmuch_database_reopen: %s\n", notmuch_status_to_string (status)); diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h index 2fbf7ab9..731757cc 100644 --- a/lib/notmuch-private.h +++ b/lib/notmuch-private.h @@ -206,9 +206,6 @@ _notmuch_message_id_compressed (void *ctx, const char *message_id); notmuch_status_t _notmuch_database_ensure_writable (notmuch_database_t *notmuch); -notmuch_status_t -_notmuch_database_reopen (notmuch_database_t *notmuch); - void _notmuch_database_log (notmuch_database_t *notmuch, const char *format, ...); diff --git a/lib/notmuch.h b/lib/notmuch.h index 5a5d99c0..0c13f607 100644 --- a/lib/notmuch.h +++ b/lib/notmuch.h @@ -879,6 +879,13 @@ notmuch_database_find_message_by_filename (notmuch_database_t *notmuch, notmuch_tags_t * notmuch_database_get_all_tags (notmuch_database_t *db); +/** + * Reopen an open notmuch database. + * + */ +notmuch_status_t +notmuch_database_reopen (notmuch_database_t *db, notmuch_database_mode_t mode); + /** * Create a new query for 'database'. * -- 2.30.0