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 83580429E26 for ; Mon, 11 Jul 2011 13:07:34 -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 2S4AJVSJZhI0 for ; Mon, 11 Jul 2011 13:07:33 -0700 (PDT) Received: from dmz-mailsec-scanner-1.mit.edu (DMZ-MAILSEC-SCANNER-1.MIT.EDU [18.9.25.12]) by olra.theworths.org (Postfix) with ESMTP id 6654D431FD0 for ; Mon, 11 Jul 2011 13:07:33 -0700 (PDT) X-AuditID: 1209190c-b7c65ae00000117c-a5-4e1b5808f572 Received: from mailhub-auth-4.mit.edu ( [18.7.62.39]) by dmz-mailsec-scanner-1.mit.edu (Symantec Messaging Gateway) with SMTP id 32.E4.04476.8085B1E4; Mon, 11 Jul 2011 16:07:36 -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 p6BK7Qt2003027; Mon, 11 Jul 2011 16:07:26 -0400 Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91]) (authenticated bits=0) (User authenticated as amdragon@ATHENA.MIT.EDU) by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id p6BK7MqJ024260 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); Mon, 11 Jul 2011 16:07:25 -0400 (EDT) Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.72) (envelope-from ) id 1QgMl6-00037M-3O; Mon, 11 Jul 2011 16:07:12 -0400 Date: Mon, 11 Jul 2011 16:07:12 -0400 From: Austin Clements To: Louis Rilling Subject: Re: [PATCH 2/2] tags_to_maildir_flags: Don't rename if no flags change Message-ID: <20110711200712.GB25558@mit.edu> References: <87d3hzgemi.fsf@yoom.home.cworth.org> <1310394978-11883-3-git-send-email-l.rilling@av7.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1310394978-11883-3-git-send-email-l.rilling@av7.net> User-Agent: Mutt/1.5.20 (2009-06-14) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFuplleLIzCtJLcpLzFFi42IRYrdT1+WNkPYzOH6M1eLmzzlsFudbXrFY XL85k9mB2ePuunXsHrs3P2DxeLbqFnMAcxSXTUpqTmZZapG+XQJXxusPP5kK3klWLDrWxNrA +Eu4i5GTQ0LAROLA7TOMELaYxIV769m6GLk4hAT2MUr0n/jJCOFsYJR4c+sqVOYkk0TD9bvM EM4SRomGt9uAyjg4WARUJWZ/5gMZxSagIbFt/3KwsSJA4Z3tR9lBbGYBa4ldPV+ZQWxhgUCJ QzN2MoHYvAI6Esd2tYLVCwlkSjz/8JwdIi4ocXLmExaIXi2JG/9eMoGsYhaQllj+jwMkzCng JDHj+22wElEBFYlr+9vZJjAKzULSPQtJ9yyE7gWMzKsYZVNyq3RzEzNzilOTdYuTE/PyUot0 DfVyM0v0UlNKNzGCQp1TkmcH45uDSocYBTgYlXh4V0pL+wmxJpYVV+YeYpTkYFIS5WUOBQrx JeWnVGYkFmfEF5XmpBYfYpTgYFYS4d3NDpTjTUmsrEotyodJSXOwKInzlnv/9xUSSE8sSc1O TS1ILYLJynBwKEnwvg8DahQsSk1PrUjLzClBSDNxcIIM5wEa/gCkhre4IDG3ODMdIn+KUVFK nPcbSEIAJJFRmgfXC0tFrxjFgV4R5n0HUsUDTGNw3a+ABjMBDX4tLQkyuCQRISXVwOgyKTTm RM/zdTUl8999fuove/OhsmCaW6jcuQyVbW9WF9r42roYH/zcoROX0jq9aaKCfca+sE3Hb9+f IysTOWXDsr1svZuFQ0QnfXzo4vXzgLFq8JIND8RCSv5+1127IY1pjylP4JNOXZ2oo/7WbP2H zwV8k3s7JSrgxHUn9t98bkmbJ3IbvlNiKc5INNRiLipOBAByGLZyIAMAAA== Cc: notmuch@notmuchmail.org 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: Mon, 11 Jul 2011 20:07:34 -0000 I worry that this may compound the confusion caused by mutt's handling of the new flag, but I suppose people aren't likely to manipulate any of the other maildir-synchronized flags without also marking the message as seen. At any rate, the change is certainly correct technically. A few nits below. Quoth Louis Rilling on Jul 11 at 4:36 pm: > notmuch_message_tags_to_maildir_flags() unconditionally moves messages from > maildir directory "new/" to maildir directory "cur/", which makes messages lose > their "new" status in the MUA. However some users want to keep this "new" > status after, for instance, an auto-tagging of new messages. > > However, as Austin mentioned and according to the maildir specification, > messages living in "new/" are not allowed to have flags, even if mutt allows it > to happen. For this reason, this patch prevents moving messages from "new/" to > "cur/", only if no flags have to be changed. It's hopefully enough to satisfy > mutt (and maybe other MUAs showing the "new" status) users checking the "new" > status. > > Signed-off-by: Louis Rilling > --- > lib/message.cc | 12 +++++++++++- > 1 files changed, 11 insertions(+), 1 deletions(-) > > diff --git a/lib/message.cc b/lib/message.cc > index 64b6cf8..131d99b 100644 > --- a/lib/message.cc > +++ b/lib/message.cc > @@ -1139,7 +1139,7 @@ _get_maildir_flag_actions (notmuch_message_t *message, > * compute the new maildir filename. > * > * If the existing filename is in the directory "new", the new > - * filename will be in the directory "cur". > + * filename will be in the directory "cur", unless no flags are changed. > * > * After a sequence of ":2," in the filename, any subsequent > * single-character flags will be added or removed according to the > @@ -1162,6 +1162,7 @@ _new_maildir_filename (void *ctx, > char *filename_new, *dir; > char flag_map[128]; > int flags_in_map = 0; > + bool flags_changed = false; The convention in notmuch is to use notmuch_bool_t, TRUE, and FALSE (though, admittedly, I don't know why; avoiding C99-isms?) > unsigned int i; > char *s; > > @@ -1202,6 +1203,7 @@ _new_maildir_filename (void *ctx, > if (flag_map[flag] == 0) { > flag_map[flag] = 1; > flags_in_map++; > + flags_changed = true; > } > } > > @@ -1210,9 +1212,17 @@ _new_maildir_filename (void *ctx, > if (flag_map[flag]) { > flag_map[flag] = 0; > flags_in_map--; > + flags_changed = true; > } > } > > + /* No need to rename. Messages in new/ can be kept in new/. > + * Note: We don't even try to fix buggy messages having flags and living in > + * new/. It's not our business. > + */ > + if (!flags_changed) > + return NULL; > + NULL generally indicates an error in notmuch and is currently used that way in _new_maildir_filename, so even though the caller currently doesn't really care, I'd lean against overloading it to indicate that the filename doesn't need to change. Despite the slight inefficiency, I would recommend returning talloc_strdup (ctx, filename). > filename_new = (char *) talloc_size (ctx, > info - filename + > strlen (":2,") + flags_in_map + 1);