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 A345D429E25 for ; Mon, 11 Jul 2011 17:04: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 axBW01qvmoDk for ; Mon, 11 Jul 2011 17:04:57 -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 E6A70431FB6 for ; Mon, 11 Jul 2011 17:04:56 -0700 (PDT) X-AuditID: 1209190d-b7bdeae0000004f8-53-4e1b8f4e8406 Received: from mailhub-auth-2.mit.edu ( [18.7.62.36]) by dmz-mailsec-scanner-2.mit.edu (Symantec Messaging Gateway) with SMTP id 88.FC.01272.E4F8B1E4; Mon, 11 Jul 2011 20:03:26 -0400 (EDT) Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) by mailhub-auth-2.mit.edu (8.13.8/8.9.2) with ESMTP id p6C04tEs025954; Mon, 11 Jul 2011 20:04:56 -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 p6C04spP000258 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); Mon, 11 Jul 2011 20:04:55 -0400 (EDT) Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.72) (envelope-from ) id 1QgQSy-0003JE-0Q; Mon, 11 Jul 2011 20:04:44 -0400 Date: Mon, 11 Jul 2011 20:04:43 -0400 From: Austin Clements To: Louis Rilling Subject: Re: [PATCH v2] tags_to_maildir_flags: Don't rename if no flags change Message-ID: <20110712000443.GE25558@mit.edu> References: <20110711223805.GC3583@localdomain> <1310424115-18850-1-git-send-email-l.rilling@av7.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1310424115-18850-1-git-send-email-l.rilling@av7.net> User-Agent: Mutt/1.5.20 (2009-06-14) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupmleLIzCtJLcpLzFFi42IRYrdT0fXrl/Yz2HvD1OLmzzlsFudbXrFY XL85k9mB2ePuunXsHrs3P2DxeLbqFnMAcxSXTUpqTmZZapG+XQJXxu/2HWwFf0QqrmzNamD8 xN/FyMkhIWAicfnOXhYIW0ziwr31bCC2kMA+RonGt65djFxA9gZGiT2LnrJDOCeZJO6saGKE cJYwSpz+vpYZpIVFQFVi0f5brCA2m4CGxLb9yxlBbBGg+M72o+wgNrOAtcSunq9A9RwcwgIB ElvXGoGEeQV0JPb8u8UOsTldYuunk2wQcUGJkzOfsEC0aknc+PeSCaSVWUBaYvk/DpAwp4CT xIveDWAlogIqEtf2t7NNYBSahaR7FpLuWQjdCxiZVzHKpuRW6eYmZuYUpybrFicn5uWlFuka 6eVmluilppRuYgSFOack7w7GdweVDjEKcDAq8fCulpb2E2JNLCuuzD3EKMnBpCTK+6sPKMSX lJ9SmZFYnBFfVJqTWnyIUYKDWUmEN6QWKMebklhZlVqUD5OS5mBREudV8/7vC/RvYklqdmpq QWoRTFaGg0NJgpcFGM9CgkWp6akVaZk5JQhpJg5OkOE8QMMtQWp4iwsSc4sz0yHypxgVpcR5 L4JcJACSyCjNg+uFpaFXjOJArwjzeoO08wBTGFz3K6DBTECDX0tLggwuSURISTUw2h1XrDz/ MPXU3sdK9SF9AWVPat4f9Xw884BIc57J1C/Tr6xdmlb7bskJnswvASnPszeUnv/lwHbUXHUR E/un5c/tZ6kFS94LvjjbLjfxNrvnenWOzBc1MpPfnHnAfc97iQxzyjMV1xgDJ6O5H1K21ks0 ndCzerTpVJ6Q+8xur73PY/L6vaZuUmIpzkg01GIuKk4EAOOY1soeAwAA 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: Tue, 12 Jul 2011 00:04:57 -0000 LGTM. Quoth Louis Rilling on Jul 12 at 12:41 am: > 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. > > Changelog: > * v2: Fix bool type as well as NULL returned despite having no errors (Austin > Clements) > > 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..3f8c4ba 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; > + notmuch_bool_t flags_changed = FALSE; > 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 talloc_strdup (ctx, filename); > + > filename_new = (char *) talloc_size (ctx, > info - filename + > strlen (":2,") + flags_in_map + 1);