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 oIHmFWBwHV8dEgAA0tVLHw (envelope-from ) for ; Sun, 26 Jul 2020 12:00:32 +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 ACmiEWBwHV9vegAAbx9fmQ (envelope-from ) for ; Sun, 26 Jul 2020 12:00:32 +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) server-signature RSA-PSS (2048 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 063839403AE for ; Sun, 26 Jul 2020 12:00:32 +0000 (UTC) Received: from [144.217.243.247] (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id BC47727BCB; Sun, 26 Jul 2020 08:00:13 -0400 (EDT) Received: from fethera.tethera.net (fethera.tethera.net [IPv6:2607:5300:60:c5::1]) by mail.notmuchmail.org (Postfix) with ESMTP id 3390520056 for ; Sun, 26 Jul 2020 08:00:03 -0400 (EDT) Received: by fethera.tethera.net (Postfix, from userid 1001) id E905C60AB8; Sun, 26 Jul 2020 08:00:02 -0400 (EDT) Received: (nullmailer pid 1448361 invoked by uid 1000); Sun, 26 Jul 2020 11:59:43 -0000 From: David Bremner To: notmuch@notmuchmail.org Cc: David Bremner Subject: [PATCH 07/13] lib: catch exceptions in n_directory_get_child_files Date: Sun, 26 Jul 2020 08:59:25 -0300 Message-Id: <20200726115931.1448056-8-david@tethera.net> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200726115931.1448056-1-david@tethera.net> References: <20200726115931.1448056-1-david@tethera.net> MIME-Version: 1.0 Message-ID-Hash: Q6Z2D5GOBZP5VMQE46QC643FSYPAXBSI X-Message-ID-Hash: Q6Z2D5GOBZP5VMQE46QC643FSYPAXBSI 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 2607:5300:201:3100::1657 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Spam-Score: 0.03 X-TUID: 2O4ZhSc5ozCc Also clarify API in error case. --- lib/directory.cc | 12 ++++++++---- lib/notmuch.h | 2 ++ test/T563-lib-directory.sh | 1 - 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/directory.cc b/lib/directory.cc index eb59d24d..044cd680 100644 --- a/lib/directory.cc +++ b/lib/directory.cc @@ -264,15 +264,19 @@ notmuch_filenames_t * notmuch_directory_get_child_files (notmuch_directory_t *directory) { char *term; - notmuch_filenames_t *child_files; + notmuch_filenames_t *child_files = NULL; term = talloc_asprintf (directory, "%s%u:", _find_prefix ("file-direntry"), directory->document_id); - child_files = _create_filenames_for_terms_with_prefix (directory, - directory->notmuch, - term); + try { + child_files = _create_filenames_for_terms_with_prefix (directory, + directory->notmuch, + term); + } catch (Xapian::Error &error) { + LOG_XAPIAN_EXCEPTION (directory, error); + } talloc_free (term); diff --git a/lib/notmuch.h b/lib/notmuch.h index 03db3b24..d52fa976 100644 --- a/lib/notmuch.h +++ b/lib/notmuch.h @@ -2148,6 +2148,8 @@ notmuch_directory_get_mtime (notmuch_directory_t *directory); * * The returned filenames will be the basename-entries only (not * complete paths). + * + * Returns NULL if it triggers a Xapian exception */ notmuch_filenames_t * notmuch_directory_get_child_files (notmuch_directory_t *directory); diff --git a/test/T563-lib-directory.sh b/test/T563-lib-directory.sh index bbd12e12..739469a6 100755 --- a/test/T563-lib-directory.sh +++ b/test/T563-lib-directory.sh @@ -58,7 +58,6 @@ EOF test_expect_equal_file EXPECTED OUTPUT test_begin_subtest "get child filenames for a closed db" -test_subtest_known_broken cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} { notmuch_filenames_t *children; -- 2.27.0