notmuch-search-toggle-order and notmuch-tree
[notmuch-archives.git] / e2 / 4234198971e6f518e2ab48bd31ffc1d1ae43d0
1 Return-Path: <jani@nikula.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 92B9F431FC0\r
6         for <notmuch@notmuchmail.org>; Mon, 22 Sep 2014 02:55:46 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References"\r
9 X-Spam-Flag: NO\r
10 X-Spam-Score: -0.7\r
11 X-Spam-Level: \r
12 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
13         tests=[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 twU0Ql7jBTp9 for <notmuch@notmuchmail.org>;\r
17         Mon, 22 Sep 2014 02:55:40 -0700 (PDT)\r
18 Received: from mail-wi0-f170.google.com (mail-wi0-f170.google.com\r
19         [209.85.212.170]) (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 7E704431FDA\r
22         for <notmuch@notmuchmail.org>; Mon, 22 Sep 2014 02:55:02 -0700 (PDT)\r
23 Received: by mail-wi0-f170.google.com with SMTP id fb4so2489708wid.1\r
24         for <notmuch@notmuchmail.org>; Mon, 22 Sep 2014 02:55:01 -0700 (PDT)\r
25 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
26         d=1e100.net; s=20130820;\r
27         h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\r
28         :references:in-reply-to:references;\r
29         bh=n5qzNbP0UoBxlIxPTFASBybVy4EgoUOqeh3ijN5ZfcM=;\r
30         b=B6W0nCstiMyb635HidESCTrlFbz6MSUynqUYmvphUYaxggFME0MBLu38nG5cnoT+Rv\r
31         oAU2nQOkA3eoP+xCbg23Dx3QThvyFVfBd4Wr+ToBz7s9bZRSOQf/usw/j443IHrQLKN1\r
32         PRH1tZUmRw0DvkWHrjNwOQuFCyamKs38n+aJcrpCpK2s7PsUNf1d6sEO8dxjhgJANduu\r
33         PP38WbNer/azLUEYMmof+NO6mbJO8EE1qYUT3121Ys4HpYU7z7Pda4vHAswWMyK29Eyk\r
34         RFmzp/zpE75xAHztHTXT5ugzvpzQPH0fHMF7XCqTUs11YWQZgb8Sh3FsrBT5Lx1FaUyZ\r
35         UaKA==\r
36 X-Gm-Message-State:\r
37  ALoCoQlSQNtcG1Df7nOGLPisFLbPmBJGwPF8wAPPDrDh8jyZXu5YLWROx4bGFQDn3jfnP6gN5zql\r
38 X-Received: by 10.194.78.41 with SMTP id y9mr19032742wjw.24.1411379701415;\r
39         Mon, 22 Sep 2014 02:55:01 -0700 (PDT)\r
40 Received: from localhost ([2001:4b98:dc0:43:216:3eff:fe1b:25f3])\r
41         by mx.google.com with ESMTPSA id p1sm11721573wjy.22.2014.09.22.02.55.00\r
42         for <multiple recipients>\r
43         (version=TLSv1.1 cipher=RC4-SHA bits=128/128);\r
44         Mon, 22 Sep 2014 02:55:00 -0700 (PDT)\r
45 From: Jani Nikula <jani@nikula.org>\r
46 To: notmuch@notmuchmail.org\r
47 Subject: [PATCH 10/11] cli/insert: require succesful message indexing for\r
48         success status\r
49 Date: Mon, 22 Sep 2014 11:55:01 +0200\r
50 Message-Id:\r
51  <84d4706c8d556769aa3330bf6ca9cfe92fb6213e.1411379395.git.jani@nikula.org>\r
52 X-Mailer: git-send-email 1.7.2.5\r
53 In-Reply-To: <cover.1411379395.git.jani@nikula.org>\r
54 References: <cover.1411379395.git.jani@nikula.org>\r
55 In-Reply-To: <cover.1411379395.git.jani@nikula.org>\r
56 References: <cover.1411379395.git.jani@nikula.org>\r
57 X-BeenThere: notmuch@notmuchmail.org\r
58 X-Mailman-Version: 2.1.13\r
59 Precedence: list\r
60 List-Id: "Use and development of the notmuch mail system."\r
61         <notmuch.notmuchmail.org>\r
62 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
63         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
64 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
65 List-Post: <mailto:notmuch@notmuchmail.org>\r
66 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
67 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
68         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
69 X-List-Received-Date: Mon, 22 Sep 2014 09:55:46 -0000\r
70 \r
71 Add --keep option to keep any remaining stuff in index or file. We\r
72 could distinguish between failures to index and failures to apply tags\r
73 or maildir sync, but for simplicity just have one.\r
74 ---\r
75  notmuch-insert.c    |   20 +++++++++++++++-----\r
76  test/T070-insert.sh |    2 +-\r
77  2 files changed, 16 insertions(+), 6 deletions(-)\r
78 \r
79 diff --git a/notmuch-insert.c b/notmuch-insert.c\r
80 index 80f52d4..f27b9cb 100644\r
81 --- a/notmuch-insert.c\r
82 +++ b/notmuch-insert.c\r
83 @@ -433,6 +433,7 @@ DONE:\r
84  int\r
85  notmuch_insert_command (notmuch_config_t *config, int argc, char *argv[])\r
86  {\r
87 +    notmuch_status_t status;\r
88      notmuch_database_t *notmuch;\r
89      struct sigaction action;\r
90      const char *db_path;\r
91 @@ -442,6 +443,7 @@ notmuch_insert_command (notmuch_config_t *config, int argc, char *argv[])\r
92      char *query_string = NULL;\r
93      const char *folder = NULL;\r
94      notmuch_bool_t create_folder = FALSE;\r
95 +    notmuch_bool_t keep = FALSE;\r
96      notmuch_bool_t synchronize_flags;\r
97      const char *maildir;\r
98      char *newpath;\r
99 @@ -451,6 +453,7 @@ notmuch_insert_command (notmuch_config_t *config, int argc, char *argv[])\r
100      notmuch_opt_desc_t options[] = {\r
101         { NOTMUCH_OPT_STRING, &folder, "folder", 0, 0 },\r
102         { NOTMUCH_OPT_BOOLEAN, &create_folder, "create-folder", 0, 0 },\r
103 +       { NOTMUCH_OPT_BOOLEAN, &keep, "keep", 0, 0 },\r
104         { NOTMUCH_OPT_END, 0, 0, 0, 0 }\r
105      };\r
106  \r
107 @@ -525,11 +528,18 @@ notmuch_insert_command (notmuch_config_t *config, int argc, char *argv[])\r
108         return EXIT_FAILURE;\r
109      }\r
110  \r
111 -    /* Add the message to the index.\r
112 -     * Even if adding the message to the notmuch database fails,\r
113 -     * the message is on disk and we consider the delivery completed. */\r
114 -    add_file (notmuch, newpath, tag_ops, synchronize_flags, TRUE);\r
115 +    /* Index the message. */\r
116 +    status = add_file (notmuch, newpath, tag_ops, synchronize_flags, keep);\r
117 +    if (status) {\r
118 +       if (keep) {\r
119 +           status = NOTMUCH_STATUS_SUCCESS;\r
120 +       } else {\r
121 +           /* If maildir flag sync failed, this might fail. */\r
122 +           unlink (newpath);\r
123 +       }\r
124 +    }\r
125  \r
126      notmuch_database_destroy (notmuch);\r
127 -    return EXIT_SUCCESS;\r
128 +\r
129 +    return status ? EXIT_FAILURE : EXIT_SUCCESS;\r
130  }\r
131 diff --git a/test/T070-insert.sh b/test/T070-insert.sh\r
132 index ea9db07..aacc643 100755\r
133 --- a/test/T070-insert.sh\r
134 +++ b/test/T070-insert.sh\r
135 @@ -23,7 +23,7 @@ test_expect_code 1 "Insert zero-length file" \\r
136  \r
137  # This test is a proxy for other errors that may occur while trying to\r
138  # add a message to the notmuch database, e.g. database locked.\r
139 -test_expect_code 0 "Insert non-message" \\r
140 +test_expect_code 1 "Insert non-message" \\r
141      "echo bad_message | notmuch insert"\r
142  \r
143  test_begin_subtest "Database empty so far"\r
144 -- \r
145 1.7.2.5\r
146 \r