1 Return-Path: <meskio@noblezabaturra.org>
\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 6B15240DEED
\r
6 for <notmuch@notmuchmail.org>; Fri, 19 Nov 2010 07:41:22 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-1.9 tagged_above=-999 required=5
\r
12 tests=[BAYES_00=-1.9] autolearn=ham
\r
13 Received: from olra.theworths.org ([127.0.0.1])
\r
14 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id NhrncPgbpVFI for <notmuch@notmuchmail.org>;
\r
16 Fri, 19 Nov 2010 07:41:10 -0800 (PST)
\r
17 Received: from heal.cauterized.net (heal.cauterized.net [89.140.131.167])
\r
18 by olra.theworths.org (Postfix) with ESMTP id BE70A40DEEB
\r
19 for <notmuch@notmuchmail.org>; Fri, 19 Nov 2010 07:41:09 -0800 (PST)
\r
20 Received: from localhost.localdomain (pb-d-128-141-44-147.cern.ch
\r
22 (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
\r
23 (No client certificate requested)
\r
24 by heal.cauterized.net (Postfix) with ESMTPSA id EAD9F7024564;
\r
25 Fri, 19 Nov 2010 16:41:06 +0100 (CET)
\r
26 From: meskio@sindominio.net
\r
27 To: notmuch@notmuchmail.org
\r
28 Subject: [PATCH] Including 'unread' tag to mails without maildir flags
\r
29 Date: Fri, 19 Nov 2010 16:41:04 +0100
\r
30 Message-Id: <1290181264-5900-1-git-send-email-meskio@sindominio.net>
\r
31 X-Mailer: git-send-email 1.7.1
\r
32 In-Reply-To: <20101118153744.GE3049@blackspot>
\r
33 References: <20101118153744.GE3049@blackspot>
\r
34 X-BeenThere: notmuch@notmuchmail.org
\r
35 X-Mailman-Version: 2.1.13
\r
37 List-Id: "Use and development of the notmuch mail system."
\r
38 <notmuch.notmuchmail.org>
\r
39 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
40 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
41 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
42 List-Post: <mailto:notmuch@notmuchmail.org>
\r
43 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
44 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
45 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
46 X-List-Received-Date: Fri, 19 Nov 2010 15:41:22 -0000
\r
48 From: Ruben Pollan <meskio@sindominio.net>
\r
50 Some mail fetchers, like fetchmail, leaves the email without ':2,' at the end of
\r
51 the filename. Notmuch didn't detect this emails as maildir, it didn't add the
\r
52 maildir flags to them.
\r
54 Now it detects if a mail is in a maildir by the directory structure, and add its
\r
55 maildir flags correctly.
\r
57 lib/message.cc | 87 +++++++++++++++++++++++++++++---------------------------
\r
58 1 files changed, 45 insertions(+), 42 deletions(-)
\r
60 diff --git a/lib/message.cc b/lib/message.cc
\r
61 index 225b7e9..996c1df 100644
\r
62 --- a/lib/message.cc
\r
63 +++ b/lib/message.cc
\r
64 @@ -854,6 +854,47 @@ notmuch_message_remove_tag (notmuch_message_t *message, const char *tag)
\r
65 return NOTMUCH_STATUS_SUCCESS;
\r
68 +/* Is the given filename within a maildir directory?
\r
70 + * Specifically, is the final directory component of 'filename' either
\r
71 + * "cur" or "new". If so, return a pointer to that final directory
\r
72 + * component within 'filename'. If not, return NULL.
\r
74 + * A non-NULL return value is guaranteed to be a valid string pointer
\r
75 + * pointing to the characters "new/" or "cur/", (but not
\r
76 + * NUL-terminated).
\r
78 +static const char *
\r
79 +_filename_is_in_maildir (const char *filename)
\r
81 + const char *slash, *dir = NULL;
\r
83 + /* Find the last '/' separating directory from filename. */
\r
84 + slash = strrchr (filename, '/');
\r
85 + if (slash == NULL)
\r
88 + /* Jump back 4 characters to where the previous '/' will be if the
\r
89 + * directory is named "cur" or "new". */
\r
90 + if (slash - filename < 4)
\r
95 + if (*slash != '/')
\r
100 + if (STRNCMP_LITERAL (dir, "cur/") == 0 ||
\r
101 + STRNCMP_LITERAL (dir, "new/") == 0)
\r
110 notmuch_message_maildir_flags_to_tags (notmuch_message_t *message)
\r
112 @@ -871,11 +912,14 @@ notmuch_message_maildir_flags_to_tags (notmuch_message_t *message)
\r
114 filename = notmuch_filenames_get (filenames);
\r
116 + if (! _filename_is_in_maildir(filename))
\r
118 + seen_maildir_info = 1;
\r
120 flags = strstr (filename, ":2,");
\r
124 - seen_maildir_info = 1;
\r
127 combined_flags = talloc_strdup_append (combined_flags, flags);
\r
128 @@ -910,47 +954,6 @@ notmuch_message_maildir_flags_to_tags (notmuch_message_t *message)
\r
132 -/* Is the given filename within a maildir directory?
\r
134 - * Specifically, is the final directory component of 'filename' either
\r
135 - * "cur" or "new". If so, return a pointer to that final directory
\r
136 - * component within 'filename'. If not, return NULL.
\r
138 - * A non-NULL return value is guaranteed to be a valid string pointer
\r
139 - * pointing to the characters "new/" or "cur/", (but not
\r
140 - * NUL-terminated).
\r
142 -static const char *
\r
143 -_filename_is_in_maildir (const char *filename)
\r
145 - const char *slash, *dir = NULL;
\r
147 - /* Find the last '/' separating directory from filename. */
\r
148 - slash = strrchr (filename, '/');
\r
149 - if (slash == NULL)
\r
152 - /* Jump back 4 characters to where the previous '/' will be if the
\r
153 - * directory is named "cur" or "new". */
\r
154 - if (slash - filename < 4)
\r
159 - if (*slash != '/')
\r
164 - if (STRNCMP_LITERAL (dir, "cur/") == 0 ||
\r
165 - STRNCMP_LITERAL (dir, "new/") == 0)
\r
173 /* From the set of tags on 'message' and the flag2tag table, compute a
\r
174 * set of maildir-flag actions to be taken, (flags that should be
\r
175 * either set or cleared).
\r