[PATCH 2/2] fix thread breakage via ghost-on-removal
Daniel Kahn Gillmor
dkg at fifthhorseman.net
Fri Apr 1 16:31:55 PDT 2016
This is the solution to T590-thread-breakage.sh that just adds a ghost
message after removing each message.
It leaks information about whether we've ever seen a given message id,
but it's a fairly simple implementation.
Note that _resolve_message_id_to_thread_id also introduces new
message_ids to the database, so i think just searching for a given
message ID may introduce the same metadata leakage.
---
lib/database.cc | 28 ++++++++++++++++++++++++++--
1 file changed, 26 insertions(+), 2 deletions(-)
diff --git a/lib/database.cc b/lib/database.cc
index 3b342f1..6c9e34a 100644
--- a/lib/database.cc
+++ b/lib/database.cc
@@ -2557,9 +2557,33 @@ notmuch_database_remove_message (notmuch_database_t *notmuch,
if (status == NOTMUCH_STATUS_SUCCESS && message) {
status = _notmuch_message_remove_filename (message, filename);
- if (status == NOTMUCH_STATUS_SUCCESS)
+ if (status == NOTMUCH_STATUS_SUCCESS) {
+ const char *mid, *tid;
+ notmuch_message_t *ghost;
+ notmuch_private_status_t private_status;
+
+ mid = notmuch_message_get_message_id (message);
+ tid = notmuch_message_get_thread_id (message);
+ /* remove the message */
_notmuch_message_delete (message);
- else if (status == NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID)
+
+ /* and reintroduce a ghost in its place */
+ ghost = _notmuch_message_create_for_message_id (notmuch, mid, &private_status);
+ if (private_status == NOTMUCH_PRIVATE_STATUS_SUCCESS) {
+ /* this is deeply weird, and we should not have
+ gotten into this state. is there a better
+ error message to return here? */
+ status = NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID;
+ } else if (private_status == NOTMUCH_PRIVATE_STATUS_NO_DOCUMENT_FOUND) {
+ private_status = _notmuch_message_initialize_ghost (ghost, tid);
+ if (! private_status) {
+ _notmuch_message_sync (ghost);
+ notmuch_message_destroy (ghost);
+ }
+ }
+
+ status = COERCE_STATUS (private_status, "Error converting to ghost message");
+ } else if (status == NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID)
_notmuch_message_sync (message);
notmuch_message_destroy (message);
--
2.8.0.rc3
More information about the notmuch
mailing list