aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Carl Worth <cworth@cworth.org>2010-11-11 02:55:13 -0800
committerGravatar Carl Worth <cworth@cworth.org>2010-11-11 03:40:19 -0800
commit404db1de90f6e5a66c34077b38b18a39c955ece2 (patch)
tree96e019d068f30a87e50a436052093494382c085c
parent38d82b07c4462d2b3e4bc1ad3d24586be348db1d (diff)
maildir_flags_to_tags: Avoid interpreting "no info" as "no flags set".
If a filename has no maildir info at all, (that is, it does not contain the sequence ":2,"), we consider this distinct from a filename with an empty maildir info, (the ":2," separator is present, but no flags characters follow). Specifically, we regard a missing info field as providing no information, so tags will remain unchanged. On the other hand, an info field that is present but has no flags set will cause various tags to be cleared, (or in the case of "unread", added). This fixes the "remove info" case of the maildir-sync tests in the test suite.
-rw-r--r--lib/message.cc8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/message.cc b/lib/message.cc
index 39036ecc..b8128505 100644
--- a/lib/message.cc
+++ b/lib/message.cc
@@ -868,6 +868,7 @@ notmuch_message_maildir_flags_to_tags (notmuch_message_t *message)
const char *filename;
char *combined_flags = talloc_strdup (message, "");
unsigned i;
+ int seen_maildir_info = 0;
for (filenames = notmuch_message_get_filenames (message);
notmuch_filenames_valid (filenames);
@@ -879,11 +880,18 @@ notmuch_message_maildir_flags_to_tags (notmuch_message_t *message)
if (! flags)
continue;
+ seen_maildir_info = 1;
flags += 3;
combined_flags = talloc_strdup_append (combined_flags, flags);
}
+ /* If none of the filenames have any maildir info field (not even
+ * an empty info with no flags set) then there's no information to
+ * go on, so do nothing. */
+ if (! seen_maildir_info)
+ return NOTMUCH_STATUS_SUCCESS;
+
status = notmuch_message_freeze (message);
if (status)
return status;