From: Austin Clements Date: Sat, 9 Jun 2012 19:14:17 +0000 (+2000) Subject: [PATCH v2 4/5] lib: Treat messages in new/ as maildir messages with no flags set X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=06c4c77a01a2f9ba36a22b12a2cccf70d8748bf5;p=notmuch-archives.git [PATCH v2 4/5] lib: Treat messages in new/ as maildir messages with no flags set --- diff --git a/a6/bc5f2a953e3254376132b889474e9cd49734c9 b/a6/bc5f2a953e3254376132b889474e9cd49734c9 new file mode 100644 index 000000000..18cfb458c --- /dev/null +++ b/a6/bc5f2a953e3254376132b889474e9cd49734c9 @@ -0,0 +1,134 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id 33B81431FC3 + for ; Sat, 9 Jun 2012 12:14:57 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -0.7 +X-Spam-Level: +X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 + tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id wGiO8uc-tsxG for ; + Sat, 9 Jun 2012 12:14:55 -0700 (PDT) +Received: from dmz-mailsec-scanner-2.mit.edu (DMZ-MAILSEC-SCANNER-2.MIT.EDU + [18.9.25.13]) + by olra.theworths.org (Postfix) with ESMTP id 13A55431FAF + for ; Sat, 9 Jun 2012 12:14:55 -0700 (PDT) +X-AuditID: 1209190d-b7fd56d000000933-f8-4fd3a0aef381 +Received: from mailhub-auth-4.mit.edu ( [18.7.62.39]) + by dmz-mailsec-scanner-2.mit.edu (Symantec Messaging Gateway) with SMTP + id E1.8E.02355.EA0A3DF4; Sat, 9 Jun 2012 15:14:54 -0400 (EDT) +Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) + by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id q59JEsqq017467; + Sat, 9 Jun 2012 15:14:54 -0400 +Received: from drake.dyndns.org + (209-6-116-242.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com + [209.6.116.242]) (authenticated bits=0) + (User authenticated as amdragon@ATHENA.MIT.EDU) + by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q59JEqVV026108 + (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); + Sat, 9 Jun 2012 15:14:53 -0400 (EDT) +Received: from amthrax by drake.dyndns.org with local (Exim 4.77) + (envelope-from ) + id 1SdR75-0000wv-PS; Sat, 09 Jun 2012 15:14:19 -0400 +From: Austin Clements +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 +Message-Id: <1339269258-3542-5-git-send-email-amdragon@mit.edu> +X-Mailer: git-send-email 1.7.10 +In-Reply-To: <1339269258-3542-1-git-send-email-amdragon@mit.edu> +References: <1338742656-11640-1-git-send-email-amdragon@mit.edu> + <1339269258-3542-1-git-send-email-amdragon@mit.edu> +X-Brightmail-Tracker: + H4sIAAAAAAAAA+NgFtrFIsWRmVeSWpSXmKPExsUixG6nrrtuwWV/g8OtihZN050trt+cyezA + 5HHr/mt2j2erbjEHMEVx2aSk5mSWpRbp2yVwZfy48JWt4I5gxZZ/d5kaGGfydTFyckgImEh8 + OXSWFcIWk7hwbz1bFyMXh5DAPkaJx737WEASQgLrGSWuvBSASDxkkthxdgc7hDOXUeLe6bVs + IFVsAhoS2/YvZwSxRQSkJXbenQ00loODWcBc4mZLHEhYWCBSYtvFhUwgNouAqkRT/3d2kBJe + AXuJJd8FIY6Ql3h6vw9sIqeAg8Sz79MZIW4ok3h2ejbbBEb+BYwMqxhlU3KrdHMTM3OKU5N1 + i5MT8/JSi3SN9HIzS/RSU0o3MYKCiFOSdwfju4NKhxgFOBiVeHi15C/5C7EmlhVX5h5ilORg + UhLl/TL/sr8QX1J+SmVGYnFGfFFpTmrxIUYJDmYlEd6tTEDlvCmJlVWpRfkwKWkOFiVx3gSu + s/5CAumJJanZqakFqUUwWRkODiUJ3jxgtAgJFqWmp1akZeaUIKSZODhBhvMADX8Dspi3uCAx + tzgzHSJ/ilFRSpzXFKRZACSRUZoH1wuL8leM4kCvCPNag1TxABMEXPcroMFMQINboy6ADC5J + REhJNTDKzzkrWN+j7KGyan3lZ6tUL77zh0u3LasQNUk+KnNwq6JHaMEUPva04IvVWw7mLInP + r5F/4FT7WnRDxBLvfOscC47SufefPjsuf55h/ss9LWeylJRLRMItUh57yt1a9fhEbgHPypY3 + Wu0umj7Lbx5q5RLrfPRTimXlqVvrf09flP/8v2V63n0lluKMREMt5qLiRACDHwiDzQIAAA== +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Sat, 09 Jun 2012 19:14:57 -0000 + +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 +