[PATCH v2 4/5] lib: Treat messages in new/ as maildir messages with no flags set
authorAustin Clements <amdragon@MIT.EDU>
Sat, 9 Jun 2012 19:14:17 +0000 (15:14 +2000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:47:39 +0000 (09:47 -0800)
a6/bc5f2a953e3254376132b889474e9cd49734c9 [new file with mode: 0644]

diff --git a/a6/bc5f2a953e3254376132b889474e9cd49734c9 b/a6/bc5f2a953e3254376132b889474e9cd49734c9
new file mode 100644 (file)
index 0000000..18cfb45
--- /dev/null
@@ -0,0 +1,134 @@
+Return-Path: <amdragon@mit.edu>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 33B81431FC3\r
+       for <notmuch@notmuchmail.org>; Sat,  9 Jun 2012 12:14:57 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+       tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id wGiO8uc-tsxG for <notmuch@notmuchmail.org>;\r
+       Sat,  9 Jun 2012 12:14:55 -0700 (PDT)\r
+Received: from dmz-mailsec-scanner-2.mit.edu (DMZ-MAILSEC-SCANNER-2.MIT.EDU\r
+       [18.9.25.13])\r
+       by olra.theworths.org (Postfix) with ESMTP id 13A55431FAF\r
+       for <notmuch@notmuchmail.org>; Sat,  9 Jun 2012 12:14:55 -0700 (PDT)\r
+X-AuditID: 1209190d-b7fd56d000000933-f8-4fd3a0aef381\r
+Received: from mailhub-auth-4.mit.edu ( [18.7.62.39])\r
+       by dmz-mailsec-scanner-2.mit.edu (Symantec Messaging Gateway) with SMTP\r
+       id E1.8E.02355.EA0A3DF4; Sat,  9 Jun 2012 15:14:54 -0400 (EDT)\r
+Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])\r
+       by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id q59JEsqq017467; \r
+       Sat, 9 Jun 2012 15:14:54 -0400\r
+Received: from drake.dyndns.org\r
+       (209-6-116-242.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com\r
+       [209.6.116.242]) (authenticated bits=0)\r
+       (User authenticated as amdragon@ATHENA.MIT.EDU)\r
+       by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q59JEqVV026108\r
+       (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
+       Sat, 9 Jun 2012 15:14:53 -0400 (EDT)\r
+Received: from amthrax by drake.dyndns.org with local (Exim 4.77)\r
+       (envelope-from <amdragon@mit.edu>)\r
+       id 1SdR75-0000wv-PS; Sat, 09 Jun 2012 15:14:19 -0400\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v2 4/5] lib: Treat messages in new/ as maildir messages with\r
+       no flags set\r
+Date: Sat,  9 Jun 2012 15:14:17 -0400\r
+Message-Id: <1339269258-3542-5-git-send-email-amdragon@mit.edu>\r
+X-Mailer: git-send-email 1.7.10\r
+In-Reply-To: <1339269258-3542-1-git-send-email-amdragon@mit.edu>\r
+References: <1338742656-11640-1-git-send-email-amdragon@mit.edu>\r
+       <1339269258-3542-1-git-send-email-amdragon@mit.edu>\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFtrFIsWRmVeSWpSXmKPExsUixG6nrrtuwWV/g8OtihZN050trt+cyezA\r
+       5HHr/mt2j2erbjEHMEVx2aSk5mSWpRbp2yVwZfy48JWt4I5gxZZ/d5kaGGfydTFyckgImEh8\r
+       OXSWFcIWk7hwbz1bFyMXh5DAPkaJx737WEASQgLrGSWuvBSASDxkkthxdgc7hDOXUeLe6bVs\r
+       IFVsAhoS2/YvZwSxRQSkJXbenQ00loODWcBc4mZLHEhYWCBSYtvFhUwgNouAqkRT/3d2kBJe\r
+       AXuJJd8FIY6Ql3h6vw9sIqeAg8Sz79MZIW4ok3h2ejbbBEb+BYwMqxhlU3KrdHMTM3OKU5N1\r
+       i5MT8/JSi3SN9HIzS/RSU0o3MYKCiFOSdwfju4NKhxgFOBiVeHi15C/5C7EmlhVX5h5ilORg\r
+       UhLl/TL/sr8QX1J+SmVGYnFGfFFpTmrxIUYJDmYlEd6tTEDlvCmJlVWpRfkwKWkOFiVx3gSu\r
+       s/5CAumJJanZqakFqUUwWRkODiUJ3jxgtAgJFqWmp1akZeaUIKSZODhBhvMADX8Dspi3uCAx\r
+       tzgzHSJ/ilFRSpzXFKRZACSRUZoH1wuL8leM4kCvCPNag1TxABMEXPcroMFMQINboy6ADC5J\r
+       REhJNTDKzzkrWN+j7KGyan3lZ6tUL77zh0u3LasQNUk+KnNwq6JHaMEUPva04IvVWw7mLInP\r
+       r5F/4FT7WnRDxBLvfOscC47SufefPjsuf55h/ss9LWeylJRLRMItUh57yt1a9fhEbgHPypY3\r
+       Wu0umj7Lbx5q5RLrfPRTimXlqVvrf09flP/8v2V63n0lluKMREMt5qLiRACDHwiDzQIAAA==\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Sat, 09 Jun 2012 19:14:57 -0000\r
+\r
+Previously, notmuch new only synchronized maildir flags to tags for\r
+files with a maildir "info" part.  Since messages in new/ don't have\r
+an info part, notmuch would ignore them for flag-to-tag\r
+synchronization.\r
+\r
+This patch makes notmuch consider messages in new/ to be legitimate\r
+maildir messages that simply have no maildir flags set.  The most\r
+visible effect of this is that such messages now automatically get the\r
+unread tag.\r
+---\r
+ lib/message.cc    |   20 +++++++++++++-------\r
+ test/maildir-sync |    1 -\r
+ 2 files changed, 13 insertions(+), 8 deletions(-)\r
+\r
+diff --git a/lib/message.cc b/lib/message.cc\r
+index bbac2ff..978de06 100644\r
+--- a/lib/message.cc\r
++++ b/lib/message.cc\r
+@@ -1090,13 +1090,19 @@ notmuch_message_maildir_flags_to_tags (notmuch_message_t *message)\r
+           continue;\r
+ \r
+       flags = strstr (filename, ":2,");\r
+-      if (! flags)\r
+-          continue;\r
+-\r
+-      seen_maildir_info = 1;\r
+-      flags += 3;\r
+-\r
+-      combined_flags = talloc_strdup_append (combined_flags, flags);\r
++      if (flags) {\r
++          seen_maildir_info = 1;\r
++          flags += 3;\r
++          combined_flags = talloc_strdup_append (combined_flags, flags);\r
++      } else if (STRNCMP_LITERAL (dir, "new/") == 0) {\r
++          /* Messages are delivered to new/ with no "info" part, but\r
++           * they effectively have default maildir flags.  According\r
++           * to the spec, we should ignore the info part for\r
++           * messages in new/, but some MUAs (mutt) can set maildir\r
++           * flags on messages in new/, so we're liberal in what we\r
++           * accept. */\r
++          seen_maildir_info = 1;\r
++      }\r
+     }\r
+ \r
+     /* If none of the filenames have any maildir info field (not even\r
+diff --git a/test/maildir-sync b/test/maildir-sync\r
+index 6360fd2..01348d3 100755\r
+--- a/test/maildir-sync\r
++++ b/test/maildir-sync\r
+@@ -167,7 +167,6 @@ notmuch tag +unread +draft -flagged subject:"Non-compliant maildir info"\r
+ test_expect_equal "$(cd $MAIL_DIR/cur/; ls non-compliant*)" "non-compliant-maildir-info:2,These-are-not-flags-in-ASCII-order-donottouch"\r
+ \r
+ test_begin_subtest "Files in new/ get default synchronized tags"\r
+-test_subtest_known_broken\r
+ OLDCONFIG=$(notmuch config get new.tags)\r
+ notmuch config set new.tags test\r
+ add_message [subject]='"File in new/"' [dir]=new [filename]='file-in-new'\r
+-- \r
+1.7.10\r
+\r