1 Return-Path: <prvs=267104af38=davidben@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 C71D7431FD7
\r
6 for <notmuch@notmuchmail.org>; Tue, 23 Feb 2010 18:28:35 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-2.351 tagged_above=-999 required=5 tests=[AWL=0.248,
\r
12 BAYES_00=-2.599] autolearn=ham
\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 y9CI-WdAINbz for <notmuch@notmuchmail.org>;
\r
16 Tue, 23 Feb 2010 18:28:35 -0800 (PST)
\r
17 Received: from dmz-mailsec-scanner-4.mit.edu (DMZ-MAILSEC-SCANNER-4.MIT.EDU
\r
19 by olra.theworths.org (Postfix) with ESMTP id D880D431FCF
\r
20 for <notmuch@notmuchmail.org>; Tue, 23 Feb 2010 18:28:30 -0800 (PST)
\r
21 X-AuditID: 1209190f-b7c94ae00000096e-5d-4b848d92b612
\r
22 Received: from mailhub-auth-2.mit.edu (MAILHUB-AUTH-2.MIT.EDU [18.7.62.36])
\r
23 by dmz-mailsec-scanner-4.mit.edu (Symantec Brightmail Gateway) with
\r
24 SMTP id FC.CF.02414.29D848B4; Tue, 23 Feb 2010 21:23:14 -0500 (EST)
\r
25 Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])
\r
26 by mailhub-auth-2.mit.edu (8.13.8/8.9.2) with ESMTP id o1O2NEZU008876;
\r
27 Tue, 23 Feb 2010 21:23:14 -0500
\r
28 Received: from localhost.localdomain (ET-NINETY-THREE.MIT.EDU [18.208.1.93])
\r
29 (authenticated bits=0)
\r
30 (User authenticated as davidben@ATHENA.MIT.EDU)
\r
31 by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id o1O2NTiu021532
\r
32 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT);
\r
33 Tue, 23 Feb 2010 21:23:35 -0500 (EST)
\r
34 From: David Benjamin <davidben@MIT.EDU>
\r
35 To: notmuch@notmuchmail.org
\r
36 Date: Tue, 23 Feb 2010 21:23:02 -0500
\r
37 Message-Id: <1266978183-19698-4-git-send-email-davidben@mit.edu>
\r
38 X-Mailer: git-send-email 1.7.0.18.g39b3
\r
39 In-Reply-To: <1266978183-19698-1-git-send-email-davidben@mit.edu>
\r
40 References: <1266978183-19698-1-git-send-email-davidben@mit.edu>
\r
41 X-Brightmail-Tracker: AAAAARMIvZ4=
\r
42 Subject: [notmuch] [PATCH 3/4] Configure the database separately from mail
\r
44 X-BeenThere: notmuch@notmuchmail.org
\r
45 X-Mailman-Version: 2.1.13
\r
47 List-Id: "Use and development of the notmuch mail system."
\r
48 <notmuch.notmuchmail.org>
\r
49 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
50 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
51 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
52 List-Post: <mailto:notmuch@notmuchmail.org>
\r
53 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
54 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
55 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
56 X-List-Received-Date: Wed, 24 Feb 2010 02:28:35 -0000
\r
58 Signed-off-by: David Benjamin <davidben@mit.edu>
\r
60 notmuch-client.h | 7 ++++++
\r
61 notmuch-config.c | 62 ++++++++++++++++++++++++++++++++++++++++--------------
\r
62 notmuch-new.c | 14 ++++-------
\r
63 3 files changed, 58 insertions(+), 25 deletions(-)
\r
65 diff --git a/notmuch-client.h b/notmuch-client.h
\r
66 index 1a676d2..010fdc7 100644
\r
67 --- a/notmuch-client.h
\r
68 +++ b/notmuch-client.h
\r
69 @@ -148,6 +148,13 @@ void
\r
70 notmuch_config_set_database_path (notmuch_config_t *config,
\r
71 const char *database_path);
\r
74 +notmuch_config_get_database_notmuch_path (notmuch_config_t *config);
\r
77 +notmuch_config_set_database_notmuch_path (notmuch_config_t *config,
\r
78 + const char *database_notmuch_path);
\r
80 notmuch_database_t *
\r
81 notmuch_config_open_database (notmuch_config_t *config,
\r
82 notmuch_database_mode_t mode);
\r
83 diff --git a/notmuch-config.c b/notmuch-config.c
\r
84 index 58a28b1..b20047c 100644
\r
85 --- a/notmuch-config.c
\r
86 +++ b/notmuch-config.c
\r
87 @@ -58,6 +58,7 @@ struct _notmuch_config {
\r
90 char *database_path;
\r
91 + char *database_notmuch_path;
\r
93 char *user_primary_email;
\r
94 char **user_other_email;
\r
95 @@ -151,6 +152,8 @@ get_username_from_passwd_file (void *ctx)
\r
97 * database_path: $HOME/mail
\r
99 + * database_notmuch_path: database_path/.notmuch
\r
101 * user_name: From /etc/passwd
\r
103 * user_primary_mail: $EMAIL variable if set, otherwise
\r
104 @@ -195,6 +198,7 @@ notmuch_config_open (void *ctx,
\r
105 config->key_file = g_key_file_new ();
\r
107 config->database_path = NULL;
\r
108 + config->database_notmuch_path = NULL;
\r
109 config->user_name = NULL;
\r
110 config->user_primary_email = NULL;
\r
111 config->user_other_email = NULL;
\r
112 @@ -351,6 +355,45 @@ notmuch_config_set_database_path (notmuch_config_t *config,
\r
114 talloc_free (config->database_path);
\r
115 config->database_path = NULL;
\r
116 + /* In case this path is dynamically generated */
\r
117 + talloc_free (config->database_notmuch_path);
\r
118 + config->database_notmuch_path = NULL
\r
122 +notmuch_config_get_database_notmuch_path (notmuch_config_t *config)
\r
124 + const char *path;
\r
125 + char *notmuch_path;
\r
127 + if (config->database_notmuch_path == NULL) {
\r
128 + notmuch_path = g_key_file_get_string (config->key_file,
\r
129 + "database", "notmuch_path", NULL);
\r
130 + if (notmuch_path) {
\r
131 + config->database_notmuch_path = talloc_strdup (config, notmuch_path);
\r
132 + free (notmuch_path);
\r
134 + path = notmuch_config_get_database_path (config);
\r
135 + if (path != NULL) {
\r
136 + notmuch_path = talloc_asprintf (config, "%s/%s",
\r
137 + path, ".notmuch");
\r
138 + config->database_notmuch_path = notmuch_path;
\r
143 + return config->database_notmuch_path;
\r
147 +notmuch_config_set_database_notmuch_path (notmuch_config_t *config,
\r
148 + const char *database_notmuch_path)
\r
150 + g_key_file_set_string (config->key_file,
\r
151 + "database", "notmuch_path", database_notmuch_path);
\r
153 + talloc_free (config->database_notmuch_path);
\r
154 + config->database_notmuch_path = NULL;
\r
157 notmuch_database_t *
\r
158 @@ -358,26 +401,13 @@ notmuch_config_open_database (notmuch_config_t *config,
\r
159 notmuch_database_mode_t mode)
\r
161 const char *path = NULL;
\r
162 - char *db_path = NULL;
\r
163 + const char *notmuch_path = NULL;
\r
164 notmuch_database_t *notmuch = NULL;
\r
166 path = notmuch_config_get_database_path (config);
\r
167 - if (path == NULL) {
\r
168 - fprintf (stderr, "Error: Cannot create a database for a NULL path.\n");
\r
172 - if (asprintf (&db_path, "%s/%s", path, ".notmuch") == -1) {
\r
174 - fprintf (stderr, "Out of memory\n");
\r
178 - notmuch = notmuch_database_open (path, db_path, mode);
\r
179 + notmuch_path = notmuch_config_get_database_notmuch_path (config);
\r
184 + notmuch = notmuch_database_open (path, notmuch_path, mode);
\r
188 diff --git a/notmuch-new.c b/notmuch-new.c
\r
189 index d24dab9..d36edd5 100644
\r
190 --- a/notmuch-new.c
\r
191 +++ b/notmuch-new.c
\r
192 @@ -713,7 +713,7 @@ notmuch_new_command (void *ctx, int argc, char *argv[])
\r
195 const char *db_path;
\r
196 - char *dot_notmuch_path;
\r
197 + const char *notmuch_path;
\r
198 struct sigaction action;
\r
199 _filename_node_t *f;
\r
200 int renamed_files, removed_files;
\r
201 @@ -737,10 +737,9 @@ notmuch_new_command (void *ctx, int argc, char *argv[])
\r
204 db_path = notmuch_config_get_database_path (config);
\r
205 + notmuch_path = notmuch_config_get_database_notmuch_path (config);
\r
207 - dot_notmuch_path = talloc_asprintf (ctx, "%s/%s", db_path, ".notmuch");
\r
209 - if (stat (dot_notmuch_path, &st)) {
\r
210 + if (stat (notmuch_path, &st)) {
\r
214 @@ -749,11 +748,11 @@ notmuch_new_command (void *ctx, int argc, char *argv[])
\r
217 printf ("Found %d total files (that's not much mail).\n", count);
\r
218 - notmuch = notmuch_database_create (db_path, dot_notmuch_path);
\r
219 + notmuch = notmuch_database_create (db_path, notmuch_path);
\r
220 add_files_state.total_files = count;
\r
222 notmuch = notmuch_database_open (db_path,
\r
223 - dot_notmuch_path,
\r
225 NOTMUCH_DATABASE_MODE_READ_WRITE);
\r
226 if (notmuch == NULL)
\r
228 @@ -782,9 +781,6 @@ notmuch_new_command (void *ctx, int argc, char *argv[])
\r
229 action.sa_flags = SA_RESTART;
\r
230 sigaction (SIGINT, &action, NULL);
\r
232 - talloc_free (dot_notmuch_path);
\r
233 - dot_notmuch_path = NULL;
\r
235 add_files_state.processed_files = 0;
\r
236 add_files_state.added_messages = 0;
\r
237 gettimeofday (&add_files_state.tv_start, NULL);
\r