From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id OPG1NMtjJGQ5oQAASxT56A (envelope-from ) for ; Wed, 29 Mar 2023 18:14:03 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id QJeuM8tjJGSqBAEAG6o9tA (envelope-from ) for ; Wed, 29 Mar 2023 18:14:03 +0200 Received: from mail.notmuchmail.org (yantan.tethera.net [135.181.149.255]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id A0D362DE0D for ; Wed, 29 Mar 2023 18:14:03 +0200 (CEST) Received: from yantan.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 67C7C5F837; Wed, 29 Mar 2023 16:13:46 +0000 (UTC) Received: from out-46.mta0.migadu.com (out-46.mta0.migadu.com [91.218.175.46]) by mail.notmuchmail.org (Postfix) with ESMTPS id 17DB95F7EC for ; Wed, 29 Mar 2023 16:13:41 +0000 (UTC) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=boula.in; s=key1; t=1680106420; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IiT4flrXkInG/rUgCubeuOXivmiqofBXJzd569VPjrQ=; b=pCSYtgN4W29zY92/6u9sXcX+fd4ZtTLgtA+/m0NdgJDhMisPsA63GVVDQh0WHNRjvlheH6 NxMJfqPbFNqSLJKLeOb9fkP4QQURwnZAL1zMyKBUV7UzmBMK90311QTi46QO+wBbRUUYel u95VztMxOZ8rLlhIQYmsJ5Wa76AigIBnOYdKP92AEVSRTVTvR3+l/fLYGp/2YY7Lnpmmd6 iK6Us6zz6OzqCwyFn/RpE5FCXmlDL3KWQGmaoPMGvXc08ObmQ47mSQXbkq7vbZaGkhBmor r+nN6r/3EN62F2aE5LA1edDIsN6fvgt+cDnigIktn1IssOgt7GF8nMJmwmphdQ== From: Kevin Boulain To: notmuch@notmuchmail.org Subject: [PATCH v2 4/5] lib/message-property: sync removed properties to the database Date: Wed, 29 Mar 2023 18:13:32 +0200 Message-Id: <20230329161333.154904-4-kevin@boula.in> In-Reply-To: <87v8ij6ben.fsf@tethera.net> References: <87v8ij6ben.fsf@tethera.net> MIME-Version: 1.0 Message-ID-Hash: QKWO3AX57UHJFAWQYZEL6GZ6KHNBJSIK X-Message-ID-Hash: QKWO3AX57UHJFAWQYZEL6GZ6KHNBJSIK X-MailFrom: kevin@boula.in X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-notmuch.notmuchmail.org-0 CC: Kevin Boulain X-Mailman-Version: 3.3.3 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Migadu-Country: DE X-Migadu-Flow: FLOW_IN ARC-Seal: i=1; s=key1; d=yhetil.org; t=1680106443; a=rsa-sha256; cv=none; b=Y5MiebTgfkSXG53aHnksAZ7PB4wyNzxAj7RcyGzWoXLtuaQmvobe0tAb2rpe3fD4LpDRHq xBZor2WM4Z5uwpY01QkwnnrEzI80JOc7LHJJPbW6y5iFYQ68ZKi4vEwudpsMX8WHjLUvby d9oM+odiLSUB7OJGmnt8t3w3S+siFihmKwGQ6aBJacQBpEH9VP0K3bpLV6bvYMNTjHqCD5 esVQgr4U0PDjE0nbFv+dNBKx9OvP3q4IXjGr+28q97n5LvZoBva64IBXqno0wYte3YA2MY mOGh0Cza9KnhfYpZz7sgODfkvntqBYoOGOSB7MfXX0qbkKOTkRy5vVi1sZswUg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=boula.in header.s=key1 header.b=pCSYtgN4; dmarc=fail reason="SPF not aligned (relaxed)" header.from=boula.in (policy=quarantine); spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 135.181.149.255 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1680106443; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-owner:list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=u5nX9+uGjKCAnvZMI8bdsKo19gRs8YQwu2fnipw1rkM=; b=p8djwhrVjaYao7TCqOnI+ZcoVoGlcZgLomFqWtdRLeb74KMhCd6CMnpHniG9NBF2b/XgU4 zS93uIi8LTvIJ7F/shyp8/RwG5EfI/zGphYfXdbUac37kMLD7/Ll3ALvJA6plyUvp2Hsga 74ay/G2hscGqAuzoKRw6hgJU0eFwyUJLSwF88Vt8tCwi84730jLDvNsJgR96DJTlTUS5xj j1uB8wO1KJcTDgRtI/x3rcdTPDlI4B/CXV7i4MpeXN2HuH++r2PjgGWgNPOgVwWZPJVvBZ xGN4rCH23d3YLABBWip9BFeIPNzqoSj/2TSTCNp7s5ZffuUyZuZ+jprsmvr6NA== X-Migadu-Spam: Yes X-Migadu-Spam-Score: 6.00 X-Spam-Score: 6.00 X-Migadu-Queue-Id: A0D362DE0D X-Migadu-Scanner: scn0.migadu.com X-Spam: Yes Authentication-Results: aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=boula.in header.s=key1 header.b=pCSYtgN4; dmarc=fail reason="SPF not aligned (relaxed)" header.from=boula.in (policy=quarantine); spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 135.181.149.255 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-TUID: cWnVdODeoJWO _notmuch_message_remove_all_properties wasn't syncing the message back to the database but was still invalidating the metadata, giving the impression the properties had actually been removed. Also move the metadata invalidation to _notmuch_message_remove_terms to be closer to what's done in _notmuch_message_modify_property and _notmuch_message_remove_term. --- lib/message-property.cc | 4 +++- lib/message.cc | 2 ++ test/T610-message-property.sh | 9 --------- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/lib/message-property.cc b/lib/message-property.cc index d5afa30c..0d658038 100644 --- a/lib/message-property.cc +++ b/lib/message-property.cc @@ -123,7 +123,6 @@ _notmuch_message_remove_all_properties (notmuch_message_t *message, const char * if (status) return status; - _notmuch_message_invalidate_metadata (message, "property"); if (key) term_prefix = talloc_asprintf (message, "%s%s%s", _find_prefix ("property"), key, prefix ? "" : "="); @@ -133,6 +132,9 @@ _notmuch_message_remove_all_properties (notmuch_message_t *message, const char * /* XXX better error reporting ? */ _notmuch_message_remove_terms (message, term_prefix); + if (! _notmuch_message_frozen (message)) + _notmuch_message_sync (message); + return NOTMUCH_STATUS_SUCCESS; } diff --git a/lib/message.cc b/lib/message.cc index 1b1a071a..53f35dd1 100644 --- a/lib/message.cc +++ b/lib/message.cc @@ -719,6 +719,8 @@ _notmuch_message_remove_terms (notmuch_message_t *message, const char *prefix) /* Ignore failure to remove non-existent term. */ } } + + _notmuch_message_invalidate_metadata (message, "property"); } diff --git a/test/T610-message-property.sh b/test/T610-message-property.sh index ec0b7fa4..e4a4b89c 100755 --- a/test/T610-message-property.sh +++ b/test/T610-message-property.sh @@ -163,7 +163,6 @@ EOF test_expect_equal_file EXPECTED OUTPUT test_begin_subtest "notmuch_message_properties: multiple values" -test_subtest_known_broken cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} EXPECT0(notmuch_message_add_property (message, "testkey1", "bob")); EXPECT0(notmuch_message_add_property (message, "testkey1", "testvalue2")); @@ -180,7 +179,6 @@ EOF test_expect_equal_file EXPECTED OUTPUT test_begin_subtest "notmuch_message_properties: prefix" -test_subtest_known_broken cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} EXPECT0(notmuch_message_add_property (message, "testkey3", "bob3")); EXPECT0(notmuch_message_add_property (message, "testkey3", "testvalue3")); @@ -235,7 +233,6 @@ EOF test_expect_equal_file EXPECTED OUTPUT test_begin_subtest "dump message properties" -test_subtest_known_broken cat < PROPERTIES #= 4EFC743A.3060609@april.org fancy%20key%20with%20%c3%a1cc%c3%a8nts=import%20value%20with%20= testkey1=alice testkey1=bob testkey1=testvalue2 testkey3=alice3 testkey3=bob3 testkey3=testvalue3 EOF @@ -246,7 +243,6 @@ notmuch dump | grep '^#=' > OUTPUT test_expect_equal_file PROPERTIES OUTPUT test_begin_subtest "dump _only_ message properties" -test_subtest_known_broken cat < EXPECTED #notmuch-dump batch-tag:3 properties #= 4EFC743A.3060609@april.org fancy%20key%20with%20%c3%a1cc%c3%a8nts=import%20value%20with%20= testkey1=alice testkey1=bob testkey1=testvalue2 testkey3=alice3 testkey3=bob3 testkey3=testvalue3 @@ -256,7 +252,6 @@ test_expect_equal_file EXPECTED OUTPUT test_begin_subtest "restore missing message property (single line)" -test_subtest_known_broken notmuch dump | grep '^#=' > BEFORE1 cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} EXPECT0(notmuch_message_remove_property (message, "testkey1", "bob")); @@ -267,7 +262,6 @@ test_expect_equal_file PROPERTIES OUTPUT test_begin_subtest "restore missing message property (full dump)" -test_subtest_known_broken notmuch dump > BEFORE2 cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} EXPECT0(notmuch_message_remove_property (message, "testkey1", "bob")); @@ -277,7 +271,6 @@ notmuch dump | grep '^#=' > OUTPUT test_expect_equal_file PROPERTIES OUTPUT test_begin_subtest "restore clear extra message property" -test_subtest_known_broken cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} EXPECT0(notmuch_message_add_property (message, "testkey1", "charles")); EOF @@ -311,7 +304,6 @@ EOF test_expect_equal_file EXPECTED OUTPUT test_begin_subtest "msg.get_properties (python)" -test_subtest_known_broken test_python <<'EOF' import notmuch db = notmuch.Database(mode=notmuch.Database.MODE.READ_ONLY) @@ -327,7 +319,6 @@ EOF test_expect_equal_file EXPECTED OUTPUT test_begin_subtest "msg.get_properties (python, prefix)" -test_subtest_known_broken test_python <<'EOF' import notmuch db = notmuch.Database(mode=notmuch.Database.MODE.READ_ONLY)