Re: [PATCH v4 09/16] index encrypted parts when asked.
[notmuch-archives.git] / b3 / a8a3d1d6823dfe8855ccb6908d7571a84029b5
1 Return-Path: <lrilling@gmail.com>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id 00D42429E40\r
6         for <notmuch@notmuchmail.org>; Wed, 14 Sep 2011 15:24:02 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.699\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.699 tagged_above=-999 required=5\r
12         tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_FROM=0.001,\r
13         RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
14 Received: from olra.theworths.org ([127.0.0.1])\r
15         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
16         with ESMTP id UP-F2pIhojlC for <notmuch@notmuchmail.org>;\r
17         Wed, 14 Sep 2011 15:24:00 -0700 (PDT)\r
18 Received: from mail-ww0-f45.google.com (mail-ww0-f45.google.com\r
19  [74.125.82.45])        (using TLSv1 with cipher RC4-SHA (128/128 bits))        (No client\r
20  certificate requested) by olra.theworths.org (Postfix) with ESMTPS id\r
21  1545D429E37    for <notmuch@notmuchmail.org>; Wed, 14 Sep 2011 15:23:58 -0700\r
22  (PDT)\r
23 Received: by mail-ww0-f45.google.com with SMTP id 36so2235195wwi.2\r
24         for <notmuch@notmuchmail.org>; Wed, 14 Sep 2011 15:23:58 -0700 (PDT)\r
25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;\r
26         h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to\r
27         :references; bh=/7rqlCR7GlAKZ05SCid7HEDTnvMR1CKWjpXnfH5ROHY=;\r
28         b=J5G8AgDzkXV7SajD5aT1BMwDu6Bu2WrqKyTXHmfT/ZCMpC22IX+oAxX9e27lKz9e+U\r
29         C9rgQHdUTNrOCcS/HN6ObNgDIDjRI22JQtg25yM3i0GlLA1ubSppTtQcMTPUh6+57rq0\r
30         lnV0oRXu9zHMzxCbG8yc/z54FGQuDqLpFj8gA=\r
31 Received: by 10.216.133.5 with SMTP id p5mr2922817wei.87.1316039038689;\r
32         Wed, 14 Sep 2011 15:23:58 -0700 (PDT)\r
33 Received: from osdor.le-roi-du-couscous.fr ([78.222.14.116])\r
34         by mx.google.com with ESMTPS id h20sm50709wbo.22.2011.09.14.15.23.57\r
35         (version=SSLv3 cipher=OTHER); Wed, 14 Sep 2011 15:23:58 -0700 (PDT)\r
36 Sender: Louis Rilling <lrilling@gmail.com>\r
37 From: Louis Rilling <l.rilling@av7.net>\r
38 To: notmuch@notmuchmail.org\r
39 Subject: [PATCH 4/4] tags_to_maildir_flags: Don't rename if no flags change\r
40 Date: Thu, 15 Sep 2011 00:23:21 +0200\r
41 Message-Id: <1316039001-32602-5-git-send-email-l.rilling@av7.net>\r
42 X-Mailer: git-send-email 1.7.2.5\r
43 In-Reply-To: <1316039001-32602-1-git-send-email-l.rilling@av7.net>\r
44 References: <1316039001-32602-1-git-send-email-l.rilling@av7.net>\r
45 Cc: Michal Sojka <sojka@os.inf.tu-dresden.de>,\r
46         Austin Clements <amdragon@mit.edu>\r
47 X-BeenThere: notmuch@notmuchmail.org\r
48 X-Mailman-Version: 2.1.13\r
49 Precedence: list\r
50 List-Id: "Use and development of the notmuch mail system."\r
51         <notmuch.notmuchmail.org>\r
52 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
53         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
54 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
55 List-Post: <mailto:notmuch@notmuchmail.org>\r
56 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
57 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
58         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
59 X-List-Received-Date: Wed, 14 Sep 2011 22:24:04 -0000\r
60 \r
61 notmuch_message_tags_to_maildir_flags() unconditionally moves messages from\r
62 maildir directory "new/" to maildir directory "cur/", which makes messages lose\r
63 their "new" status in the MUA. However some users want to keep this "new"\r
64 status after, for instance, an auto-tagging of new messages.\r
65 \r
66 However, as Austin mentioned and according to the maildir specification,\r
67 messages living in "new/" are not allowed to have flags, even if mutt allows it\r
68 to happen. For this reason, this patch prevents moving messages from "new/" to\r
69 "cur/", only if no flags have to be changed. It's hopefully enough to satisfy\r
70 mutt (and maybe other MUAs showing the "new" status) users checking the "new"\r
71 status.\r
72 \r
73 Changelog:\r
74 * v2: Fix bool type as well as NULL returned despite having no errors (Austin\r
75       Clements)\r
76 * v4: Tag the related test (contributed by Michal Sojka) as working\r
77 \r
78 Signed-off-by: Louis Rilling <l.rilling@av7.net>\r
79 ---\r
80  lib/message.cc    |   12 +++++++++++-\r
81  test/maildir-sync |    2 +-\r
82  2 files changed, 12 insertions(+), 2 deletions(-)\r
83 \r
84 diff --git a/lib/message.cc b/lib/message.cc\r
85 index b1b2942..c003729 100644\r
86 --- a/lib/message.cc\r
87 +++ b/lib/message.cc\r
88 @@ -1139,7 +1139,7 @@ _get_maildir_flag_actions (notmuch_message_t *message,\r
89   * compute the new maildir filename.\r
90   *\r
91   * If the existing filename is in the directory "new", the new\r
92 - * filename will be in the directory "cur".\r
93 + * filename will be in the directory "cur", unless no flags are changed.\r
94   *\r
95   * After a sequence of ":2," in the filename, any subsequent\r
96   * single-character flags will be added or removed according to the\r
97 @@ -1162,6 +1162,7 @@ _new_maildir_filename (void *ctx,\r
98      char *filename_new, *dir;\r
99      char flag_map[128];\r
100      int flags_in_map = 0;\r
101 +    notmuch_bool_t flags_changed = FALSE;\r
102      unsigned int i;\r
103      char *s;\r
104  \r
105 @@ -1202,6 +1203,7 @@ _new_maildir_filename (void *ctx,\r
106         if (flag_map[flag] == 0) {\r
107             flag_map[flag] = 1;\r
108             flags_in_map++;\r
109 +           flags_changed = TRUE;\r
110         }\r
111      }\r
112  \r
113 @@ -1210,9 +1212,17 @@ _new_maildir_filename (void *ctx,\r
114         if (flag_map[flag]) {\r
115             flag_map[flag] = 0;\r
116             flags_in_map--;\r
117 +           flags_changed = TRUE;\r
118         }\r
119      }\r
120  \r
121 +    /* No need to rename. Messages in new/ can be kept in new/.\r
122 +     * Note: We don't even try to fix buggy messages having flags and living in\r
123 +     * new/. It's not our business.\r
124 +     */\r
125 +    if (!flags_changed)\r
126 +       return talloc_strdup (ctx, filename);\r
127 +\r
128      filename_new = (char *) talloc_size (ctx,\r
129                                          info - filename +\r
130                                          strlen (":2,") + flags_in_map + 1);\r
131 diff --git a/test/maildir-sync b/test/maildir-sync\r
132 index b3e90ae..e1ad81c 100755\r
133 --- a/test/maildir-sync\r
134 +++ b/test/maildir-sync\r
135 @@ -92,7 +92,7 @@ test_begin_subtest "Adding non-maildir tags does not move message from new to cu\r
136  add_message [subject]='"Message to stay in new"' [date]='"Sat, 01 Jan 2000 12:00:00 -0000"' [filename]='message-to-stay-in-new' [dir]=new\r
137  notmuch tag +donotmove subject:"Message to stay in new"\r
138  output=$(cd "$MAIL_DIR"; ls */message-to-stay-in-new*)\r
139 -test_expect_equal_failure "$output" "new/message-to-stay-in-new"\r
140 +test_expect_equal "$output" "new/message-to-stay-in-new"\r
141  \r
142  test_begin_subtest "Removing 'S' flag from existing filename adds 'unread' tag"\r
143  add_message [subject]='"Removing S flag"' [filename]='removing-s-flag:2,S' [dir]=cur\r
144 -- \r
145 1.7.2.5\r
146 \r