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 0DcJEv1jBl8uYgAA0tVLHw (envelope-from ) for ; Thu, 09 Jul 2020 00:25:33 +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 MJK8Df1jBl/VaQAAbx9fmQ (envelope-from ) for ; Thu, 09 Jul 2020 00:25:33 +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 (4096 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 9B14C9400D3 for ; Thu, 9 Jul 2020 00:25:31 +0000 (UTC) Received: from [144.217.243.247] (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 519271FAE3; Wed, 8 Jul 2020 20:25:17 -0400 (EDT) X-Greylist: delayed 475 seconds by postgrey-1.36 at nmbug; Wed, 08 Jul 2020 20:25:14 EDT Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by mail.notmuchmail.org (Postfix) with ESMTP id 3CBAB1F70A for ; Wed, 8 Jul 2020 20:25:14 -0400 (EDT) Received: by fethera.tethera.net (Postfix, from userid 1001) id 150616142B; Wed, 8 Jul 2020 20:18:39 -0400 (EDT) Received: (nullmailer pid 449328 invoked by uid 1000); Thu, 09 Jul 2020 00:17:14 -0000 From: David Bremner To: notmuch@notmuchmail.org Cc: David Bremner Subject: [PATCH 05/10] lib: handle xapian exception in n_m_remove_all_tags Date: Wed, 8 Jul 2020 21:17:04 -0300 Message-Id: <20200709001709.449217-6-david@tethera.net> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200709001709.449217-1-david@tethera.net> References: <20200709001709.449217-1-david@tethera.net> MIME-Version: 1.0 Message-ID-Hash: FDE76UHEQK7PAQMOFSFHUF4HLIN5PS3A X-Message-ID-Hash: FDE76UHEQK7PAQMOFSFHUF4HLIN5PS3A 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-Scanner: scn0 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-Spam-Score: 1.53 X-TUID: dF7/BBtOQGG+ At least the exception we already catch should be reported properly. --- lib/message.cc | 10 +++++++--- lib/notmuch.h | 6 ++++-- test/T560-lib-error.sh | 1 - 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/message.cc b/lib/message.cc index 8e090aa3..09708ed9 100644 --- a/lib/message.cc +++ b/lib/message.cc @@ -2071,16 +2071,20 @@ notmuch_message_remove_all_tags (notmuch_message_t *message) status = _notmuch_database_ensure_writable (message->notmuch); if (status) return status; + tags = notmuch_message_get_tags (message); + if (! tags) + return NOTMUCH_STATUS_XAPIAN_EXCEPTION; - for (tags = notmuch_message_get_tags (message); + for (; notmuch_tags_valid (tags); notmuch_tags_move_to_next (tags)) { tag = notmuch_tags_get (tags); private_status = _notmuch_message_remove_term (message, "tag", tag); if (private_status) { - INTERNAL_ERROR ("_notmuch_message_remove_term return unexpected value: %d\n", - private_status); + return COERCE_STATUS (private_status, + "_notmuch_message_remove_term return unexpected value: %d\n", + private_status); } } diff --git a/lib/notmuch.h b/lib/notmuch.h index 4d433698..9a19e2f7 100644 --- a/lib/notmuch.h +++ b/lib/notmuch.h @@ -1635,8 +1635,10 @@ notmuch_message_remove_tag (notmuch_message_t *message, const char *tag); * See notmuch_message_freeze for an example showing how to safely * replace tag values. * - * NOTMUCH_STATUS_READ_ONLY_DATABASE: Database was opened in read-only - * mode so message cannot be modified. + * @retval #NOTMUCH_STATUS_READ_ONLY_DATABASE: Database was opened in + * read-only mode so message cannot be modified. + * @retval #NOTMUCH_STATUS_XAPIAN_EXCEPTION: an execption was thrown + * accessing the database. */ notmuch_status_t notmuch_message_remove_all_tags (notmuch_message_t *message); diff --git a/test/T560-lib-error.sh b/test/T560-lib-error.sh index acde5786..5361be77 100755 --- a/test/T560-lib-error.sh +++ b/test/T560-lib-error.sh @@ -600,7 +600,6 @@ EOF test_expect_equal_file EXPECTED OUTPUT test_begin_subtest "Handle removing all tags with closed db" -test_subtest_known_broken cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR} { notmuch_status_t status; -- 2.27.0