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 6F9D7431FD8
\r
6 for <notmuch@notmuchmail.org>; Wed, 25 Jul 2012 06:43:56 -0700 (PDT)
\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 yE77LJAtnGW4 for <notmuch@notmuchmail.org>;
\r
17 Wed, 25 Jul 2012 06:43:55 -0700 (PDT)
\r
18 Received: from mail-yx0-f181.google.com (mail-yx0-f181.google.com
\r
19 [209.85.213.181]) (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 8EFAB431FC2
\r
22 for <notmuch@notmuchmail.org>; Wed, 25 Jul 2012 06:43:45 -0700 (PDT)
\r
23 Received: by yenl3 with SMTP id l3so889862yen.26
\r
24 for <notmuch@notmuchmail.org>; Wed, 25 Jul 2012 06:43:44 -0700 (PDT)
\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=5gUAsbjGjHAAUr5DeMqRKBb/VKH3tLLghlf8sVfp5uQ=;
\r
28 b=cAaYqSyysxg10DY/uS17kHW4r6Y459U0jv8k8ynVK4DNR6xTi8F4CLeNH7DS6UaMyX
\r
29 h9qb0QDnYIqkngoJL1u56Cy5+gS4XAac/P1Crmi3FNvqX+mYAnYSPxrY8bWy0tWmWz4O
\r
30 8GQt/Q/oWadlRe2/XQBKMqtWrOA6oQ4cocBVQM7jKG9ZdgAtofWTIJI9vXD9W5Iiz9pv
\r
31 jGYwcJ80GXMPSq+8oYJsXxjdQ7jeVpaJ5I/Hwm6D56BcLEDw4Ps5wVm5UHyfop2MZoUK
\r
32 8XdalU74FX661tSHgcE7tT/wdKBbHD7ss8JB6YTMVNx3YLbiz22uN852AoVj0G3K7eF3
\r
34 Received: by 10.66.76.170 with SMTP id l10mr12812852paw.57.1343223824578;
\r
35 Wed, 25 Jul 2012 06:43:44 -0700 (PDT)
\r
36 Received: from localhost (215.42.233.220.static.exetel.com.au.
\r
38 by mx.google.com with ESMTPS id ng8sm14418478pbc.13.2012.07.25.06.43.41
\r
39 (version=TLSv1/SSLv3 cipher=OTHER);
\r
40 Wed, 25 Jul 2012 06:43:43 -0700 (PDT)
\r
41 From: Peter Wang <novalazy@gmail.com>
\r
42 To: notmuch@notmuchmail.org
\r
43 Subject: [PATCH 06/18] insert: add new message to database
\r
44 Date: Wed, 25 Jul 2012 23:42:35 +1000
\r
45 Message-Id: <1343223767-9812-6-git-send-email-novalazy@gmail.com>
\r
46 X-Mailer: git-send-email 1.7.4.4
\r
47 In-Reply-To: <1343223767-9812-1-git-send-email-novalazy@gmail.com>
\r
48 References: <1343223767-9812-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: Wed, 25 Jul 2012 13:43:56 -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 | 44 ++++++++++++++++++++++++++++++++++++++++++++
\r
67 1 files changed, 44 insertions(+), 0 deletions(-)
\r
69 diff --git a/notmuch-insert.c b/notmuch-insert.c
\r
70 index bab1fed..dd449bc 100644
\r
71 --- a/notmuch-insert.c
\r
72 +++ b/notmuch-insert.c
\r
73 @@ -129,6 +129,42 @@ copy_fd_data (int fdin, int fdout)
\r
76 static notmuch_bool_t
\r
77 +save_database (notmuch_database_t *notmuch, const char *path)
\r
79 + notmuch_message_t *message;
\r
80 + notmuch_status_t status;
\r
82 + status = notmuch_database_add_message (notmuch, path, &message);
\r
84 + case NOTMUCH_STATUS_SUCCESS:
\r
86 + case NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID:
\r
87 + fprintf (stderr, "Warning: duplicate message.\n");
\r
90 + case NOTMUCH_STATUS_FILE_NOT_EMAIL:
\r
91 + case NOTMUCH_STATUS_READ_ONLY_DATABASE:
\r
92 + case NOTMUCH_STATUS_XAPIAN_EXCEPTION:
\r
93 + case NOTMUCH_STATUS_OUT_OF_MEMORY:
\r
94 + case NOTMUCH_STATUS_FILE_ERROR:
\r
95 + case NOTMUCH_STATUS_NULL_POINTER:
\r
96 + case NOTMUCH_STATUS_TAG_TOO_LONG:
\r
97 + case NOTMUCH_STATUS_UNBALANCED_FREEZE_THAW:
\r
98 + case NOTMUCH_STATUS_UNBALANCED_ATOMIC:
\r
99 + case NOTMUCH_STATUS_LAST_STATUS:
\r
100 + fprintf (stderr, "Error: failed to add `%s' to notmuch database: %s\n",
\r
101 + path, notmuch_status_to_string (status));
\r
105 + notmuch_message_tags_to_maildir_flags (message);
\r
107 + notmuch_message_destroy (message);
\r
112 +static notmuch_bool_t
\r
113 insert_message (void *ctx, notmuch_database_t *notmuch, int fdin,
\r
116 @@ -152,6 +188,14 @@ insert_message (void *ctx, notmuch_database_t *notmuch, int fdin,
\r
123 + ret = save_database (notmuch, newpath);
\r
126 + /* XXX maybe there should be an option to keep the file in maildir? */
\r
127 + unlink (newpath);
\r