[PATCH 05/10] lib: Indicate if there are more filenames after removal.

Austin Clements amdragon at MIT.EDU
Thu Feb 17 23:58:55 PST 2011


Make _notmuch_message_remove_filename return
NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID if the message has more filenames
and fix callers to handle this.
---
 lib/message.cc |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/lib/message.cc b/lib/message.cc
index 06747fe..635f5cf 100644
--- a/lib/message.cc
+++ b/lib/message.cc
@@ -480,6 +480,9 @@ _notmuch_message_add_filename (notmuch_message_t *message,
  * This change will not be reflected in the database until the next
  * call to _notmuch_message_sync.
  *
+ * If this message still has other filenames, returns
+ * NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID.
+ *
  * Note: This function does not remove a document from the database,
  * even if the specified filename is the only filename for this
  * message. For that functionality, see
@@ -547,6 +550,10 @@ _notmuch_message_remove_filename (notmuch_message_t *message,
 	if (strncmp ((*i).c_str (), direntry_prefix, direntry_prefix_len))
 	    break;
 
+	/* Indicate that there are filenames remaining. */
+	if (status == NOTMUCH_STATUS_SUCCESS)
+	    status = NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID;
+
 	direntry = (*i).c_str ();
 	direntry += direntry_prefix_len;
 
@@ -1235,7 +1242,8 @@ notmuch_message_tags_to_maildir_flags (notmuch_message_t *message)
 	    new_status = _notmuch_message_remove_filename (message,
 							   filename);
 	    /* Hold on to only the first error. */
-	    if (! status && new_status) {
+	    if (! status && new_status
+		&& new_status != NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID) {
 		status = new_status;
 		continue;
 	    }
-- 
1.7.2.3



More information about the notmuch mailing list