unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Austin Clements <amdragon@MIT.EDU>
To: notmuch@notmuchmail.org
Subject: [PATCH v2 4/5] lib: Treat messages in new/ as maildir messages with no flags set
Date: Sat,  9 Jun 2012 15:14:17 -0400	[thread overview]
Message-ID: <1339269258-3542-5-git-send-email-amdragon@mit.edu> (raw)
In-Reply-To: <1339269258-3542-1-git-send-email-amdragon@mit.edu>

Previously, notmuch new only synchronized maildir flags to tags for
files with a maildir "info" part.  Since messages in new/ don't have
an info part, notmuch would ignore them for flag-to-tag
synchronization.

This patch makes notmuch consider messages in new/ to be legitimate
maildir messages that simply have no maildir flags set.  The most
visible effect of this is that such messages now automatically get the
unread tag.
---
 lib/message.cc    |   20 +++++++++++++-------
 test/maildir-sync |    1 -
 2 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/lib/message.cc b/lib/message.cc
index bbac2ff..978de06 100644
--- a/lib/message.cc
+++ b/lib/message.cc
@@ -1090,13 +1090,19 @@ notmuch_message_maildir_flags_to_tags (notmuch_message_t *message)
 	    continue;
 
 	flags = strstr (filename, ":2,");
-	if (! flags)
-	    continue;
-
-	seen_maildir_info = 1;
-	flags += 3;
-
-	combined_flags = talloc_strdup_append (combined_flags, flags);
+	if (flags) {
+	    seen_maildir_info = 1;
+	    flags += 3;
+	    combined_flags = talloc_strdup_append (combined_flags, flags);
+	} else if (STRNCMP_LITERAL (dir, "new/") == 0) {
+	    /* Messages are delivered to new/ with no "info" part, but
+	     * they effectively have default maildir flags.  According
+	     * to the spec, we should ignore the info part for
+	     * messages in new/, but some MUAs (mutt) can set maildir
+	     * flags on messages in new/, so we're liberal in what we
+	     * accept. */
+	    seen_maildir_info = 1;
+	}
     }
 
     /* If none of the filenames have any maildir info field (not even
diff --git a/test/maildir-sync b/test/maildir-sync
index 6360fd2..01348d3 100755
--- a/test/maildir-sync
+++ b/test/maildir-sync
@@ -167,7 +167,6 @@ notmuch tag +unread +draft -flagged subject:"Non-compliant maildir info"
 test_expect_equal "$(cd $MAIL_DIR/cur/; ls non-compliant*)" "non-compliant-maildir-info:2,These-are-not-flags-in-ASCII-order-donottouch"
 
 test_begin_subtest "Files in new/ get default synchronized tags"
-test_subtest_known_broken
 OLDCONFIG=$(notmuch config get new.tags)
 notmuch config set new.tags test
 add_message [subject]='"File in new/"' [dir]=new [filename]='file-in-new'
-- 
1.7.10

  parent reply	other threads:[~2012-06-09 19:14 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-03 16:57 [PATCH 0/4] Synchronize maildir flags in new/ Austin Clements
2012-06-03 16:57 ` [PATCH 1/4] test: Add broken test for tag synchronization on files delivered to new/ Austin Clements
2012-06-04  7:10   ` Jani Nikula
2012-06-09 19:02     ` Austin Clements
2012-06-03 16:57 ` [PATCH 2/4] lib: Move _filename_is_in_maildir Austin Clements
2012-06-03 16:57 ` [PATCH 3/4] lib: Only synchronize maildir flags for messages in maildirs Austin Clements
2012-06-04  7:01   ` Jani Nikula
2012-06-03 16:57 ` [PATCH 4/4] lib: Treat messages in new/ as maildir messages with no flags set Austin Clements
2012-06-04  7:08   ` Jani Nikula
2012-06-09 19:14 ` [PATCH v2 0/5] Synchronize maildir flags in new/ Austin Clements
2012-06-09 19:14   ` [PATCH v2 1/5] test: Add broken test for tag synchronization on files delivered to new/ Austin Clements
2012-06-09 19:14   ` [PATCH v2 2/5] lib: Move _filename_is_in_maildir Austin Clements
2012-06-09 19:14   ` [PATCH v2 3/5] lib: Only synchronize maildir flags for messages in maildirs Austin Clements
2012-06-09 19:14   ` Austin Clements [this message]
2012-06-09 19:14   ` [PATCH v2 5/5] News for updated maildir sync semantics Austin Clements
2012-06-10  8:32   ` [PATCH v2 0/5] Synchronize maildir flags in new/ Tomi Ollila
2012-06-10 18:06   ` Jani Nikula
2012-06-10 23:20   ` David Bremner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1339269258-3542-5-git-send-email-amdragon@mit.edu \
    --to=amdragon@mit.edu \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).