database error
[notmuch-archives.git] / 82 / b96b71c1cc77ea84f794cfb04967c74e72d06b
1 Return-Path: <amdragon@mit.edu>\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 ADC72431FB6\r
6         for <notmuch@notmuchmail.org>; Wed,  3 Sep 2014 08:28:49 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -2.3\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-2.3 tagged_above=-999 required=5\r
12         tests=[RCVD_IN_DNSWL_MED=-2.3] autolearn=disabled\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id tWwbPtRSaCHq for <notmuch@notmuchmail.org>;\r
16         Wed,  3 Sep 2014 08:28:45 -0700 (PDT)\r
17 Received: from dmz-mailsec-scanner-7.mit.edu (dmz-mailsec-scanner-7.mit.edu\r
18         [18.7.68.36])\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 3B77F431FAF\r
22         for <notmuch@notmuchmail.org>; Wed,  3 Sep 2014 08:28:45 -0700 (PDT)\r
23 X-AuditID: 12074424-f79346d000004923-0d-540733aac398\r
24 Received: from mailhub-auth-4.mit.edu ( [18.7.62.39])\r
25         (using TLS with cipher AES256-SHA (256/256 bits))\r
26         (Client did not present a certificate)\r
27         by dmz-mailsec-scanner-7.mit.edu (Symantec Messaging Gateway) with SMTP\r
28         id E3.4C.18723.AA337045; Wed,  3 Sep 2014 11:28:42 -0400 (EDT)\r
29 Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11])\r
30         by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id s83FSeG5022321; \r
31         Wed, 3 Sep 2014 11:28:41 -0400\r
32 Received: from drake.dyndns.org\r
33         (static-155-212-141-65.mas.onecommunications.net [155.212.141.65])\r
34         (authenticated bits=0)\r
35         (User authenticated as amdragon@ATHENA.MIT.EDU)\r
36         by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id s83FSb0F031023\r
37         (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
38         Wed, 3 Sep 2014 11:28:40 -0400\r
39 Received: from amthrax by drake.dyndns.org with local (Exim 4.77)\r
40         (envelope-from <amdragon@mit.edu>)\r
41         id 1XPCU8-0006Lk-67; Wed, 03 Sep 2014 11:28:36 -0400\r
42 From: Austin Clements <amdragon@mit.edu>\r
43 To: notmuch@notmuchmail.org\r
44 Subject: [PATCH] cli: Be more helpful when .notmuch-config does not exist\r
45 Date: Wed,  3 Sep 2014 11:28:34 -0400\r
46 Message-Id: <1409758114-24361-1-git-send-email-amdragon@mit.edu>\r
47 X-Mailer: git-send-email 2.1.0\r
48 X-Brightmail-Tracker:\r
49  H4sIAAAAAAAAA+NgFlrKIsWRmVeSWpSXmKPExsUixG6nrrvKmD3EYOd7C4vrN2cyOzB6PFt1\r
50         izmAMYrLJiU1J7MstUjfLoErY+H16WwFV4UqTnavYmpgfM7XxcjJISFgIrH5yUFGCFtM4sK9\r
51         9WxdjFwcQgKzmSRWfPvHCuFsYJQ4uuscI4RznUni/97TUM5cRok930HKODnYBDQkft9azARi\r
52         iwhIS+y8OxsozsHBLKAm8adLBcQUFvCUWP9UEcRkEVCV6J3gA1LMK+Ag8X3uJTaII+QkNuz+\r
53         zziBkXcBI8MqRtmU3Crd3MTMnOLUZN3i5MS8vNQiXXO93MwSvdSU0k2M4BBwUdnB2HxI6RCj\r
54         AAejEg+vhx9biBBrYllxZe4hRkkOJiVR3jkG7CFCfEn5KZUZicUZ8UWlOanFhxglOJiVRHjX\r
55         SAPleFMSK6tSi/JhUtIcLErivG+trYKFBNITS1KzU1MLUotgsjIcHEoSvC8NgRoFi1LTUyvS\r
56         MnNKENJMHJwgw3mAhmsYgQwvLkjMLc5Mh8ifYtTlWNf5rZ9JiCUvPy9VSpz3C8ggAZCijNI8\r
57         uDmw2H3FKA70ljCvJsgoHmDcw016BbSECWiJWw4ryJKSRISUVAOjDE/41B2H/l96YFGWfYf/\r
58         wIH5U+o61X3Mz/l/qhNqTuryniPlpVazS1r0n4VvdJLG8W13Hi/YsPBvthCXF0f07y/qN3ZO\r
59         Y3XWZ72av3zKjSmLhdPPrpcuNup0KOlvffm5Vrr9rMfJS5s0PzxaMSlQXXi6i4ayWl56SOtb\r
60         gf6Vz3rDY52K/TKUWIozEg21mIuKEwESaxpUuAIAAA==\r
61 X-BeenThere: notmuch@notmuchmail.org\r
62 X-Mailman-Version: 2.1.13\r
63 Precedence: list\r
64 List-Id: "Use and development of the notmuch mail system."\r
65         <notmuch.notmuchmail.org>\r
66 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
67         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
68 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
69 List-Post: <mailto:notmuch@notmuchmail.org>\r
70 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
71 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
72         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
73 X-List-Received-Date: Wed, 03 Sep 2014 15:28:49 -0000\r
74 \r
75 Previously, if the user ran any subcommand that required a\r
76 configuration (e.g., notmuch new) but didn't have a configuration,\r
77 notmuch would give the rather un-friendly and un-actionable message\r
78 \r
79   Error reading configuration file .notmuch-config: No such file or directory\r
80 \r
81 Since this condition is expected for new users, this patch adds\r
82 specific handling for the file-not-found case to give a message that\r
83 is friendly and actionable.\r
84 ---\r
85  notmuch-config.c   | 26 ++++++++++++++++----------\r
86  test/T040-setup.sh |  6 ++++++\r
87  2 files changed, 22 insertions(+), 10 deletions(-)\r
88 \r
89 diff --git a/notmuch-config.c b/notmuch-config.c\r
90 index db487db..a564bca 100644\r
91 --- a/notmuch-config.c\r
92 +++ b/notmuch-config.c\r
93 @@ -283,16 +283,22 @@ notmuch_config_open (void *ctx,\r
94                                      G_KEY_FILE_KEEP_COMMENTS,\r
95                                      &error))\r
96      {\r
97 -       /* If create_new is true, then the caller is prepared for a\r
98 -        * default configuration file in the case of FILE NOT\r
99 -        * FOUND. Otherwise, any read failure is an error.\r
100 -        */\r
101 -       if (create_new &&\r
102 -           error->domain == G_FILE_ERROR &&\r
103 -           error->code == G_FILE_ERROR_NOENT)\r
104 -       {\r
105 -           g_error_free (error);\r
106 -           config->is_new = TRUE;\r
107 +       if (error->domain == G_FILE_ERROR && error->code == G_FILE_ERROR_NOENT) {\r
108 +           /* If create_new is true, then the caller is prepared for a\r
109 +            * default configuration file in the case of FILE NOT\r
110 +            * FOUND.\r
111 +            */\r
112 +           if (create_new) {\r
113 +               g_error_free (error);\r
114 +               config->is_new = TRUE;\r
115 +           } else {\r
116 +               fprintf (stderr, "Configuration file %s not found.\n"\r
117 +                        "Try running 'notmuch setup' to create a configuration.\n",\r
118 +                        config->filename);\r
119 +               talloc_free (config);\r
120 +               g_error_free (error);\r
121 +               return NULL;\r
122 +           }\r
123         }\r
124         else\r
125         {\r
126 diff --git a/test/T040-setup.sh b/test/T040-setup.sh\r
127 index 124ef1c..b1972e7 100755\r
128 --- a/test/T040-setup.sh\r
129 +++ b/test/T040-setup.sh\r
130 @@ -3,6 +3,12 @@\r
131  test_description='"notmuch setup"'\r
132  . ./test-lib.sh\r
133  \r
134 +test_begin_subtest "Notmuch new without a config suggests notmuch setup"\r
135 +output=$(notmuch --config=new-notmuch-config new 2>&1)\r
136 +test_expect_equal "$output" "\\r
137 +Configuration file new-notmuch-config not found.\r
138 +Try running 'notmuch setup' to create a configuration."\r
139 +\r
140  test_begin_subtest "Create a new config interactively"\r
141  notmuch --config=new-notmuch-config > /dev/null <<EOF\r
142  Test Suite\r
143 -- \r
144 2.1.0\r
145 \r