1 Return-Path: <m.walters@qmul.ac.uk>
\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 B5038431FB6
\r
6 for <notmuch@notmuchmail.org>; Sun, 18 Nov 2012 09:24:50 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-1.098 tagged_above=-999 required=5
\r
12 tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001,
\r
13 NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3] 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 Q+jWC5sKd53e for <notmuch@notmuchmail.org>;
\r
17 Sun, 18 Nov 2012 09:24:50 -0800 (PST)
\r
18 Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6])
\r
19 (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
\r
20 (No client certificate requested)
\r
21 by olra.theworths.org (Postfix) with ESMTPS id 0929D431FAF
\r
22 for <notmuch@notmuchmail.org>; Sun, 18 Nov 2012 09:24:50 -0800 (PST)
\r
23 Received: from smtp.qmul.ac.uk ([138.37.6.40])
\r
24 by mail2.qmul.ac.uk with esmtp (Exim 4.71)
\r
25 (envelope-from <m.walters@qmul.ac.uk>)
\r
26 id 1Ta8bw-0002od-3D; Sun, 18 Nov 2012 17:24:48 +0000
\r
27 Received: from 93-97-24-31.zone5.bethere.co.uk ([93.97.24.31] helo=localhost)
\r
28 by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.69)
\r
29 (envelope-from <m.walters@qmul.ac.uk>)
\r
30 id 1Ta8bv-0003lN-O6; Sun, 18 Nov 2012 17:24:47 +0000
\r
31 From: Mark Walters <markwalters1009@gmail.com>
\r
32 To: Peter Wang <novalazy@gmail.com>, notmuch@notmuchmail.org
\r
33 Subject: Re: [PATCH 16/18] insert: add --create-folder option
\r
34 In-Reply-To: <1343223767-9812-16-git-send-email-novalazy@gmail.com>
\r
35 References: <1343223767-9812-1-git-send-email-novalazy@gmail.com>
\r
36 <1343223767-9812-16-git-send-email-novalazy@gmail.com>
\r
37 User-Agent: Notmuch/0.14+81~g9730584 (http://notmuchmail.org) Emacs/23.4.1
\r
38 (x86_64-pc-linux-gnu)
\r
39 Date: Sun, 18 Nov 2012 17:24:46 +0000
\r
40 Message-ID: <87lidyq0wx.fsf@qmul.ac.uk>
\r
42 Content-Type: text/plain; charset=us-ascii
\r
43 X-Sender-Host-Address: 93.97.24.31
\r
44 X-QM-SPAM-Info: Sender has good ham record. :)
\r
45 X-QM-Body-MD5: f571e8dfa76fd17203e32a90cd027b42 (of first 20000 bytes)
\r
46 X-SpamAssassin-Score: -1.8
\r
47 X-SpamAssassin-SpamBar: -
\r
48 X-SpamAssassin-Report: The QM spam filters have analysed this message to
\r
50 spam. We require at least 5.0 points to mark a message as spam.
\r
51 This message scored -1.8 points.
\r
52 Summary of the scoring:
\r
53 * -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/,
\r
55 * [138.37.6.40 listed in list.dnswl.org]
\r
56 * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail
\r
57 provider * (markwalters1009[at]gmail.com)
\r
58 * 0.5 AWL AWL: From: address is in the auto white-list
\r
59 X-QM-Scan-Virus: ClamAV says the message is clean
\r
60 X-BeenThere: notmuch@notmuchmail.org
\r
61 X-Mailman-Version: 2.1.13
\r
63 List-Id: "Use and development of the notmuch mail system."
\r
64 <notmuch.notmuchmail.org>
\r
65 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
66 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
67 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
68 List-Post: <mailto:notmuch@notmuchmail.org>
\r
69 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
70 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
71 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
72 X-List-Received-Date: Sun, 18 Nov 2012 17:24:50 -0000
\r
77 On Wed, 25 Jul 2012, Peter Wang <novalazy@gmail.com> wrote:
\r
78 > Support an option to create a new folder in the maildir.
\r
80 > notmuch-insert.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
\r
81 > 1 files changed, 71 insertions(+), 0 deletions(-)
\r
83 > diff --git a/notmuch-insert.c b/notmuch-insert.c
\r
84 > index a69dfe6..380c520 100644
\r
85 > --- a/notmuch-insert.c
\r
86 > +++ b/notmuch-insert.c
\r
87 > @@ -48,6 +48,70 @@ check_folder_name (const char *folder)
\r
92 > +mkdir_parents (void *ctx, const char *path, int mode)
\r
100 > + /* First check the common case: directory already exists. */
\r
101 > + if (stat (path, &st) == 0) {
\r
102 > + return (S_ISDIR (st.st_mode)) ? 0 : -1;
\r
105 > + pathcopy = talloc_strdup (ctx, path);
\r
108 > + for (start = pathcopy; *start != '\0'; start = end + 1) {
\r
109 > + end = strchr (start + 1, '/');
\r
111 > + ret = mkdir (path, mode);
\r
115 > + ret = mkdir (pathcopy, mode);
\r
116 > + if (ret != 0 && errno != EEXIST) {
\r
121 I am a little confused by this: why is there a +1 in the start = end + 1
\r
122 line and in the end = strchr line? I believe it doesn't matter but it
\r
123 makes me wonder if I am missing something.
\r
132 > + talloc_free (pathcopy);
\r
137 > +static notmuch_bool_t
\r
138 > +maildir_create (void *ctx, const char *dir)
\r
140 > + const int mode = 0755;
\r
144 > + /* Create 'cur' directory, including parent directories. */
\r
145 > + subdir = talloc_asprintf (ctx, "%s/cur", dir);
\r
146 > + if (mkdir_parents (ctx, subdir, mode) != 0)
\r
149 > + end = subdir + strlen (subdir);
\r
151 > + /* Create 'new' directory. */
\r
152 > + strcpy (end - 3, "new");
\r
153 > + if (mkdir (subdir, mode) != 0 && errno != EEXIST)
\r
156 > + /* Create 'tmp' directory. */
\r
157 > + strcpy (end - 3, "tmp");
\r
158 > + if (mkdir (subdir, mode) != 0 && errno != EEXIST)
\r
161 > + talloc_free (subdir);
\r
165 > static notmuch_bool_t
\r
166 > safe_gethostname (char *hostname, size_t hostname_size)
\r
168 > @@ -253,6 +317,7 @@ notmuch_insert_command (void *ctx, int argc, char *argv[])
\r
169 > const char **new_tags;
\r
170 > size_t new_tags_length;
\r
171 > const char *folder = NULL;
\r
172 > + notmuch_bool_t create_folder = FALSE;
\r
173 > tag_operation_t *tag_ops;
\r
174 > int tag_ops_count = 0;
\r
176 > @@ -262,6 +327,7 @@ notmuch_insert_command (void *ctx, int argc, char *argv[])
\r
178 > notmuch_opt_desc_t options[] = {
\r
179 > { NOTMUCH_OPT_STRING, &folder, "folder", 0, 0 },
\r
180 > + { NOTMUCH_OPT_BOOLEAN, &create_folder, "create-folder", 0, 0 },
\r
181 > { NOTMUCH_OPT_END, 0, 0, 0, 0 }
\r
184 > @@ -328,6 +394,11 @@ notmuch_insert_command (void *ctx, int argc, char *argv[])
\r
187 > maildir = talloc_asprintf (ctx, "%s/%s", db_path, folder);
\r
188 > + if (create_folder && ! maildir_create (ctx, maildir)) {
\r
189 > + fprintf (stderr, "Error: creating maildir %s: %s\n",
\r
190 > + maildir, strerror (errno));
\r
194 > maildir = talloc_asprintf (ctx, "%s", db_path);
\r
199 > _______________________________________________
\r
200 > notmuch mailing list
\r
201 > notmuch@notmuchmail.org
\r
202 > http://notmuchmail.org/mailman/listinfo/notmuch
\r