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 KBjyE4PzI198YgAA0tVLHw (envelope-from ) for ; Fri, 31 Jul 2020 10:33:39 +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 CDqkD4PzI19oawAAbx9fmQ (envelope-from ) for ; Fri, 31 Jul 2020 10:33:39 +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 CAEFF9403CB for ; Fri, 31 Jul 2020 10:33:36 +0000 (UTC) Received: from [144.217.243.247] (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 9DDDB2832D; Fri, 31 Jul 2020 06:33:26 -0400 (EDT) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by mail.notmuchmail.org (Postfix) with ESMTP id 09F2F1FA22 for ; Fri, 31 Jul 2020 06:33:22 -0400 (EDT) Received: by fethera.tethera.net (Postfix, from userid 1001) id AC8E75FAA9; Fri, 31 Jul 2020 06:33:22 -0400 (EDT) Received: (nullmailer pid 1463219 invoked by uid 1000); Fri, 31 Jul 2020 10:33:19 -0000 From: David Bremner To: notmuch@notmuchmail.org Cc: David Bremner Subject: [PATCH 1/2] WIP: provide alternate API for n_d_remove_message Date: Fri, 31 Jul 2020 07:33:12 -0300 Message-Id: <20200731103313.1460011-2-david@tethera.net> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200731103313.1460011-1-david@tethera.net> References: <20200731103313.1460011-1-david@tethera.net> MIME-Version: 1.0 Message-ID-Hash: 7C6JYRSUFPCZYHPHFCDAUSTY2IACCIUG X-Message-ID-Hash: 7C6JYRSUFPCZYHPHFCDAUSTY2IACCIUG 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: dUglW5YFbOSm the idea is to reduce code duplication and extra object creation with notmuch new --- lib/database.cc | 18 ++++++++++++++---- lib/notmuch.h | 5 +++++ 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/lib/database.cc b/lib/database.cc index 75189685..72592a88 100644 --- a/lib/database.cc +++ b/lib/database.cc @@ -2035,8 +2035,16 @@ notmuch_status_t notmuch_database_remove_message (notmuch_database_t *notmuch, const char *filename) { + return notmuch_database_remove_filename (notmuch, filename, NULL); +} + +notmuch_status_t +notmuch_database_remove_filename (notmuch_database_t *notmuch, + const char *filename, + notmuch_message_t **message_ptr) { + + notmuch_message_t *message = NULL; notmuch_status_t status; - notmuch_message_t *message; status = notmuch_database_find_message_by_filename (notmuch, filename, &message); @@ -2048,12 +2056,14 @@ notmuch_database_remove_message (notmuch_database_t *notmuch, else if (status == NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID) _notmuch_message_sync (message); - notmuch_message_destroy (message); + if (message_ptr) { + *message_ptr = message; + } else { + notmuch_message_destroy (message); + } } - return status; } - notmuch_status_t notmuch_database_find_message_by_filename (notmuch_database_t *notmuch, const char *filename, diff --git a/lib/notmuch.h b/lib/notmuch.h index f9e9cc41..e4c3d2ee 100644 --- a/lib/notmuch.h +++ b/lib/notmuch.h @@ -734,6 +734,11 @@ notmuch_database_find_message_by_filename (notmuch_database_t *notmuch, const char *filename, notmuch_message_t **message); +notmuch_status_t +notmuch_database_remove_filename (notmuch_database_t *notmuch, + const char *filename, + notmuch_message_t **message); + /** * Return a list of all tags found in the database. * -- 2.27.0