From 2f103621311be5c9ee8c7b0f19442f485b24bac7 Mon Sep 17 00:00:00 2001 From: David Bremner Date: Sun, 17 Jul 2016 07:32:54 +2100 Subject: [PATCH] [PATCH] RFC: all deleting all properties with a given key --- 63/315661f9dfc325c685e2d599fafe978b298b84 | 114 ++++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 63/315661f9dfc325c685e2d599fafe978b298b84 diff --git a/63/315661f9dfc325c685e2d599fafe978b298b84 b/63/315661f9dfc325c685e2d599fafe978b298b84 new file mode 100644 index 000000000..2131fd70f --- /dev/null +++ b/63/315661f9dfc325c685e2d599fafe978b298b84 @@ -0,0 +1,114 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by arlo.cworth.org (Postfix) with ESMTP id A84DF6DE0281 + for ; Sat, 16 Jul 2016 03:33:16 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at cworth.org +X-Spam-Flag: NO +X-Spam-Score: -0.011 +X-Spam-Level: +X-Spam-Status: No, score=-0.011 tagged_above=-999 required=5 tests=[AWL=0.000, + SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01] autolearn=disabled +Received: from arlo.cworth.org ([127.0.0.1]) + by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 7cXfcqVPSQI8 for ; + Sat, 16 Jul 2016 03:33:08 -0700 (PDT) +Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) + by arlo.cworth.org (Postfix) with ESMTPS id 454566DE0243 + for ; Sat, 16 Jul 2016 03:33:07 -0700 (PDT) +Received: from remotemail by fethera.tethera.net with local (Exim 4.84) + (envelope-from ) + id 1bOMuV-0004O4-HA; Sat, 16 Jul 2016 06:33:27 -0400 +Received: (nullmailer pid 11985 invoked by uid 1000); + Sat, 16 Jul 2016 10:33:02 -0000 +From: David Bremner +To: Daniel Kahn Gillmor , + Notmuch Mail +Subject: [PATCH] RFC: all deleting all properties with a given key +Date: Sat, 16 Jul 2016 07:32:54 -0300 +Message-Id: <1468665174-11929-1-git-send-email-david@tethera.net> +X-Mailer: git-send-email 2.8.1 +In-Reply-To: <1467952610-27015-1-git-send-email-dkg@fifthhorseman.net> +References: <1467952610-27015-1-git-send-email-dkg@fifthhorseman.net> +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.20 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Sat, 16 Jul 2016 10:33:16 -0000 + +--- + +I think I somewhat prefer this way of providing the same +functionality, because the control flow is simpler. If it seems +useful, we could forward remove_property with a NULL value to +remove_all_properties + + lib/message-property.cc | 11 +++++++++-- + lib/notmuch.h | 5 ++++- + 2 files changed, 13 insertions(+), 3 deletions(-) + +diff --git a/lib/message-property.cc b/lib/message-property.cc +index edc6f2f..c6cff33 100644 +--- a/lib/message-property.cc ++++ b/lib/message-property.cc +@@ -98,16 +98,23 @@ notmuch_message_remove_property (notmuch_message_t *message, const char *key, co + } + + notmuch_status_t +-notmuch_message_remove_all_properties (notmuch_message_t *message) ++notmuch_message_remove_all_properties (notmuch_message_t *message, const char *key) + { + notmuch_status_t status; ++ const char * term_prefix; ++ + status = _notmuch_database_ensure_writable (_notmuch_message_database (message)); + if (status) + return status; + + _notmuch_message_invalidate_metadata (message, "property"); ++ if (key) ++ term_prefix = talloc_asprintf (message, "%s%s=", _find_prefix ("property"), key); ++ else ++ term_prefix = _find_prefix ("property"); ++ + /* XXX better error reporting ? */ +- _notmuch_message_remove_terms (message, _find_prefix ("property")); ++ _notmuch_message_remove_terms (message, term_prefix); + + return NOTMUCH_STATUS_SUCCESS; + } +diff --git a/lib/notmuch.h b/lib/notmuch.h +index 41aee3c..cf5de3e 100644 +--- a/lib/notmuch.h ++++ b/lib/notmuch.h +@@ -1712,6 +1712,9 @@ notmuch_message_remove_property (notmuch_message_t *message, const char *key, co + /** + * Remove all (key,value) pairs from the given message. + * ++ * @param[in,out] message message to operate on. ++ * @param[in] key key to delete properties for. If NULL, delete ++ * properties for all keys + * @returns + * - NOTMUCH_STATUS_READ_ONLY_DATABASE: Database was opened in + * read-only mode so message cannot be modified. +@@ -1719,7 +1722,7 @@ notmuch_message_remove_property (notmuch_message_t *message, const char *key, co + * + */ + notmuch_status_t +-notmuch_message_remove_all_properties (notmuch_message_t *message); ++notmuch_message_remove_all_properties (notmuch_message_t *message, const char *key); + + /**@}*/ + +-- +2.8.1 + -- 2.26.2