1 Return-Path: <novalazy@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 E846C431FAF
\r
6 for <notmuch@notmuchmail.org>; Sat, 24 Nov 2012 17:17:44 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-0.799 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_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 rjM1vO6zlpzJ for <notmuch@notmuchmail.org>;
\r
17 Sat, 24 Nov 2012 17:17:44 -0800 (PST)
\r
18 Received: from mail-pb0-f53.google.com (mail-pb0-f53.google.com
\r
19 [209.85.160.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits))
\r
20 (No client certificate requested)
\r
21 by olra.theworths.org (Postfix) with ESMTPS id 71815431FAE
\r
22 for <notmuch@notmuchmail.org>; Sat, 24 Nov 2012 17:17:44 -0800 (PST)
\r
23 Received: by mail-pb0-f53.google.com with SMTP id jt11so7944513pbb.26
\r
24 for <notmuch@notmuchmail.org>; Sat, 24 Nov 2012 17:17:44 -0800 (PST)
\r
25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
\r
26 h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references;
\r
27 bh=DjRhK8c6I2lRNYLToT7tBwQ7ZlHd5+xKAmGaPXHfU3g=;
\r
28 b=ePz181Op+HdwzmTVDtH2pAYDsy+IQk9n25XHMj8y0tkGTuaIOnfIvIUBHRjFS/C15M
\r
29 ZHuLqb8s0XAaTB/uxaR1uiGL0otu2sdZqojIcIBgYyn+KxQ1oh7eTxVq6Hm8TbHl1zPU
\r
30 LJ01e91Xh48sHdZ/KFkLxJH4E1OiOkJC5dldqMf2Bu6umufLyc2HaY3DbQAfOyC9sIR2
\r
31 4/oe5Oce71unkSpvuQgzWM8cDbZqd+upwGxk2CU3PKimsgQ/AdDJfvlBuXvdqnxbs/OS
\r
32 df+zjSvUkCXg9VWz0kZG7VziYb/l6X8SzoBVNHWOO9K0a+V6Z4iNHXa/LQrsiiVqhAtV
\r
34 Received: by 10.68.233.201 with SMTP id ty9mr26941590pbc.14.1353806264193;
\r
35 Sat, 24 Nov 2012 17:17:44 -0800 (PST)
\r
36 Received: from localhost (215.42.233.220.static.exetel.com.au.
\r
38 by mx.google.com with ESMTPS id ay5sm6176944pab.1.2012.11.24.17.17.41
\r
39 (version=TLSv1/SSLv3 cipher=OTHER);
\r
40 Sat, 24 Nov 2012 17:17:43 -0800 (PST)
\r
41 From: Peter Wang <novalazy@gmail.com>
\r
42 To: notmuch@notmuchmail.org
\r
43 Subject: [PATCH v2 07/20] insert: add new message to database
\r
44 Date: Sun, 25 Nov 2012 12:16:33 +1100
\r
45 Message-Id: <1353806206-29133-8-git-send-email-novalazy@gmail.com>
\r
46 X-Mailer: git-send-email 1.7.12.1
\r
47 In-Reply-To: <1353806206-29133-1-git-send-email-novalazy@gmail.com>
\r
48 References: <1353806206-29133-1-git-send-email-novalazy@gmail.com>
\r
49 X-BeenThere: notmuch@notmuchmail.org
\r
50 X-Mailman-Version: 2.1.13
\r
52 List-Id: "Use and development of the notmuch mail system."
\r
53 <notmuch.notmuchmail.org>
\r
54 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
55 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
56 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
57 List-Post: <mailto:notmuch@notmuchmail.org>
\r
58 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
59 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
60 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
61 X-List-Received-Date: Sun, 25 Nov 2012 01:17:45 -0000
\r
63 Add the new message to the notmuch database, renaming the file to encode
\r
64 notmuch tags as maildir flags.
\r
66 notmuch-insert.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++++-
\r
67 1 file changed, 48 insertions(+), 1 deletion(-)
\r
69 diff --git a/notmuch-insert.c b/notmuch-insert.c
\r
70 index 63a04dc..020dc29 100644
\r
71 --- a/notmuch-insert.c
\r
72 +++ b/notmuch-insert.c
\r
73 @@ -153,6 +153,44 @@ copy_fd_data (int fdin, int fdout)
\r
77 +/* Add the specified message file to the notmuch database.
\r
78 + * The file is renamed to encode notmuch tags as maildir flags. */
\r
79 +static notmuch_bool_t
\r
80 +add_file_to_database (notmuch_database_t *notmuch, const char *path)
\r
82 + notmuch_message_t *message;
\r
83 + notmuch_status_t status;
\r
85 + status = notmuch_database_add_message (notmuch, path, &message);
\r
87 + case NOTMUCH_STATUS_SUCCESS:
\r
89 + case NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID:
\r
90 + fprintf (stderr, "Warning: duplicate message.\n");
\r
93 + case NOTMUCH_STATUS_FILE_NOT_EMAIL:
\r
94 + case NOTMUCH_STATUS_READ_ONLY_DATABASE:
\r
95 + case NOTMUCH_STATUS_XAPIAN_EXCEPTION:
\r
96 + case NOTMUCH_STATUS_OUT_OF_MEMORY:
\r
97 + case NOTMUCH_STATUS_FILE_ERROR:
\r
98 + case NOTMUCH_STATUS_NULL_POINTER:
\r
99 + case NOTMUCH_STATUS_TAG_TOO_LONG:
\r
100 + case NOTMUCH_STATUS_UNBALANCED_FREEZE_THAW:
\r
101 + case NOTMUCH_STATUS_UNBALANCED_ATOMIC:
\r
102 + case NOTMUCH_STATUS_LAST_STATUS:
\r
103 + fprintf (stderr, "Error: failed to add `%s' to notmuch database: %s\n",
\r
104 + path, notmuch_status_to_string (status));
\r
108 + notmuch_message_tags_to_maildir_flags (message);
\r
110 + notmuch_message_destroy (message);
\r
115 static notmuch_bool_t
\r
116 insert_message (void *ctx, notmuch_database_t *notmuch, int fdin,
\r
118 @@ -173,8 +211,17 @@ insert_message (void *ctx, notmuch_database_t *notmuch, int fdin,
\r
126 + ret = add_file_to_database (notmuch, newpath);
\r
128 + /* XXX maybe there should be an option to keep the file in maildir? */
\r
129 + unlink (newpath);
\r