1 Return-Path: <ethan.glasser.camp@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 48AA8431FB6
\r
6 for <notmuch@notmuchmail.org>; Mon, 25 Jun 2012 13:52:39 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=1.061 tagged_above=-999 required=5
\r
12 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,
\r
13 FREEMAIL_FROM=0.001, RCVD_IN_BL_SPAMCOP_NET=1.246,
\r
14 RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_SORBS_WEB=0.614] autolearn=disabled
\r
15 Received: from olra.theworths.org ([127.0.0.1])
\r
16 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
17 with ESMTP id cu+pW-1ustVL for <notmuch@notmuchmail.org>;
\r
18 Mon, 25 Jun 2012 13:52:38 -0700 (PDT)
\r
19 Received: from mail-wg0-f45.google.com (mail-wg0-f45.google.com
\r
20 [74.125.82.45]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client
\r
21 certificate requested) by olra.theworths.org (Postfix) with ESMTPS id
\r
22 69A42431FAF for <notmuch@notmuchmail.org>; Mon, 25 Jun 2012 13:52:38 -0700
\r
24 Received: by mail-wg0-f45.google.com with SMTP id dt14so3709395wgb.2
\r
25 for <notmuch@notmuchmail.org>; Mon, 25 Jun 2012 13:52:38 -0700 (PDT)
\r
26 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
\r
27 h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references;
\r
28 bh=JtL1snjU/1Xpywll4abj5LfjBqekIq4oApY6aJ/KrtQ=;
\r
29 b=OWAwcYcv2ABvErTrNS+iGCGjLMxlhPtXgbgd+aeoKvsYz0J/1O3332q1FjWjl8FQXG
\r
30 GZmf8Rgua5MIJ/4oMlMYA1OPf0d8pZiYJHmtkM09RHb9zoyuLL4StAb9iCPOXmjO6764
\r
31 qC6KA8oQs9n/5AShw99hkNc7GjeJN7dMsxVIkltTU9HQulWJ1LuzKkLj8NR4TmzsCsBi
\r
32 b/9YYUUzTOQw5cFhnuHzDIO+8D5vJs+lvX8BlWk0VWBgfNZAlx9g5qdkiHTS3miH21hn
\r
33 ewj/ty9GmIwziqU20Jy/waoQwqFOrXqH80WPuXLNXkHYdc10Prx8ra4nY+It9/udraxp
\r
35 Received: by 10.216.194.23 with SMTP id l23mr6709137wen.121.1340657557073;
\r
36 Mon, 25 Jun 2012 13:52:37 -0700 (PDT)
\r
37 Received: from localhost ([195.24.209.21])
\r
38 by mx.google.com with ESMTPS id eb8sm8374wib.11.2012.06.25.13.52.32
\r
39 (version=TLSv1/SSLv3 cipher=OTHER);
\r
40 Mon, 25 Jun 2012 13:52:36 -0700 (PDT)
\r
41 From: Ethan Glasser-Camp <ethan.glasser.camp@gmail.com>
\r
42 To: notmuch@notmuchmail.org
\r
43 Subject: [RFC PATCH 06/14] maildir URIs can be used in tags_to_maildir_flags
\r
44 Date: Mon, 25 Jun 2012 16:51:49 -0400
\r
45 Message-Id: <1340657517-6539-2-git-send-email-ethan@betacantrips.com>
\r
46 X-Mailer: git-send-email 1.7.9.5
\r
47 In-Reply-To: <1340657517-6539-1-git-send-email-ethan@betacantrips.com>
\r
48 References: <1340657517-6539-1-git-send-email-ethan@betacantrips.com>
\r
49 X-Mailman-Approved-At: Tue, 26 Jun 2012 03:51:54 -0700
\r
50 X-BeenThere: notmuch@notmuchmail.org
\r
51 X-Mailman-Version: 2.1.13
\r
53 List-Id: "Use and development of the notmuch mail system."
\r
54 <notmuch.notmuchmail.org>
\r
55 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
56 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
57 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
58 List-Post: <mailto:notmuch@notmuchmail.org>
\r
59 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
60 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
61 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
62 X-List-Received-Date: Mon, 25 Jun 2012 20:52:39 -0000
\r
64 A better fix would probably be based on scheme.
\r
66 Signed-off-by: Ethan Glasser-Camp <ethan@betacantrips.com>
\r
68 lib/message.cc | 51 ++++++++++++++++++++++++++++++++++++++++++++++-----
\r
69 1 file changed, 46 insertions(+), 5 deletions(-)
\r
71 diff --git a/lib/message.cc b/lib/message.cc
\r
72 index c9857f5..8ecec71 100644
\r
73 --- a/lib/message.cc
\r
74 +++ b/lib/message.cc
\r
79 +#include <uriparser/Uri.h>
\r
80 #include <gmime/gmime.h>
\r
82 struct visible _notmuch_message {
\r
83 @@ -1093,7 +1094,6 @@ notmuch_message_maildir_flags_to_tags (notmuch_message_t *message)
\r
85 filename = notmuch_filenames_get (filenames);
\r
86 dir = _filename_is_in_maildir (filename);
\r
91 @@ -1304,12 +1304,46 @@ _new_maildir_filename (void *ctx,
\r
92 return filename_new;
\r
95 +/* Parses a maildir URI and returns the filename corresponding to its
\r
98 + * Returns NULL if either the URI couldn't be parsed or if the
\r
99 + * scheme isn't maildir:.
\r
102 +_get_maildir_filename (const char *filename)
\r
104 + UriParserStateA parser_state;
\r
107 + parser_state.uri = &parsed;
\r
109 + if (uriParseUriA (&parser_state, filename) != URI_SUCCESS) {
\r
110 + uriFreeUriMembersA (&parsed);
\r
114 + if (parsed.scheme.first != NULL &&
\r
115 + 0 != strncmp(parsed.scheme.first, "maildir",
\r
116 + parsed.scheme.afterLast-parsed.scheme.first)) {
\r
117 + /* Full URI with non-maildir scheme. */
\r
118 + uriFreeUriMembersA (&parsed);
\r
122 + path = (char *)parsed.pathHead->text.first - 1;
\r
123 + uriFreeUriMembersA (&parsed);
\r
130 notmuch_message_tags_to_maildir_flags (notmuch_message_t *message)
\r
132 notmuch_filenames_t *filenames;
\r
133 const char *filename;
\r
134 - char *filename_new;
\r
135 + char *filename_new, *filename_old, *filename_new_uri;
\r
136 char *to_set, *to_clear;
\r
137 notmuch_status_t status = NOTMUCH_STATUS_SUCCESS;
\r
139 @@ -1324,16 +1358,22 @@ notmuch_message_tags_to_maildir_flags (notmuch_message_t *message)
\r
140 if (! _filename_is_in_maildir (filename))
\r
143 - filename_new = _new_maildir_filename (message, filename,
\r
144 + filename_old = _get_maildir_filename (filename);
\r
145 + if (filename_old == NULL)
\r
148 + filename_new = _new_maildir_filename (message, filename_old,
\r
150 if (filename_new == NULL)
\r
153 + filename_new_uri = talloc_asprintf (message, "maildir://%s", filename_new);
\r
155 if (strcmp (filename, filename_new)) {
\r
157 notmuch_status_t new_status;
\r
159 - err = rename (filename, filename_new);
\r
160 + err = rename (filename_old, filename_new);
\r
164 @@ -1347,7 +1387,7 @@ notmuch_message_tags_to_maildir_flags (notmuch_message_t *message)
\r
167 new_status = _notmuch_message_add_filename (message,
\r
169 + filename_new_uri);
\r
170 /* Hold on to only the first error. */
\r
171 if (! status && new_status) {
\r
172 status = new_status;
\r
173 @@ -1358,6 +1398,7 @@ notmuch_message_tags_to_maildir_flags (notmuch_message_t *message)
\r
176 talloc_free (filename_new);
\r
177 + talloc_free (filename_new_uri);
\r
180 talloc_free (to_set);
\r