From: David Bremner <david@tethera.net>
To: notmuch@notmuchmail.org
Subject: [PATCH 1/2] config: add key database.upgrades
Date: Sat, 22 Mar 2014 23:26:12 -0300 [thread overview]
Message-ID: <1395541573-2417-2-git-send-email-david@tethera.net> (raw)
In-Reply-To: <1395541573-2417-1-git-send-email-david@tethera.net>
The intent is to allow the user to enable or disable automatic
database upgrades.
This doesn't do anything yet.
---
doc/man1/notmuch-config.rst | 4 ++++
notmuch-client.h | 7 +++++++
notmuch-config.c | 34 +++++++++++++++++++++++++++++-----
test/T030-config.sh | 1 +
test/T040-setup.sh | 1 +
5 files changed, 42 insertions(+), 5 deletions(-)
diff --git a/doc/man1/notmuch-config.rst b/doc/man1/notmuch-config.rst
index 3c9a568..fc7fab6 100644
--- a/doc/man1/notmuch-config.rst
+++ b/doc/man1/notmuch-config.rst
@@ -49,6 +49,10 @@ The available configuration items are described below.
within a sub-directory of the path configured here named
``.notmuch``.
+ **database.upgrades**
+ Set to ``yes`` to enable automatic in-place upgrades of the notmuch
+ database.
+
**user.name**
Your full name.
diff --git a/notmuch-client.h b/notmuch-client.h
index 278b498..3891a82 100644
--- a/notmuch-client.h
+++ b/notmuch-client.h
@@ -275,6 +275,13 @@ notmuch_config_set_database_path (notmuch_config_t *config,
const char *database_path);
const char *
+notmuch_config_get_database_upgrades (notmuch_config_t *config);
+
+void
+notmuch_config_set_database_upgrades (notmuch_config_t *config,
+ const char *database_upgrades);
+
+const char *
notmuch_config_get_user_name (notmuch_config_t *config);
void
diff --git a/notmuch-config.c b/notmuch-config.c
index 8d28653..8f4ce99 100644
--- a/notmuch-config.c
+++ b/notmuch-config.c
@@ -32,11 +32,16 @@ static const char toplevel_config_comment[] =
static const char database_config_comment[] =
" Database configuration\n"
"\n"
- " The only value supported here is 'path' which should be the top-level\n"
- " directory where your mail currently exists and to where mail will be\n"
- " delivered in the future. Files should be individual email messages.\n"
- " Notmuch will store its database within a sub-directory of the path\n"
- " configured here named \".notmuch\".\n";
+ "The following options are supported here:\n"
+ "\n"
+ "\tpath The top-level directory where your mail currently exists\n"
+ "\t and to where mail will be delivered in the future. Files\n"
+ "\t should be individual email messages. Notmuch will store\n"
+ "\t its database within a sub-directory (named .notmuch) of\n"
+ "\t the path configured here.\n"
+ "\n"
+ "\tupgrades Set to 'yes' to enable automatic database upgrades.\n"
+ "\n";
static const char new_config_comment[] =
" Configuration for \"notmuch new\"\n"
@@ -107,6 +112,7 @@ struct _notmuch_config {
notmuch_bool_t is_new;
char *database_path;
+ char *database_upgrades;
char *user_name;
char *user_primary_email;
const char **user_other_email;
@@ -265,6 +271,7 @@ notmuch_config_open (void *ctx,
config->is_new = FALSE;
config->database_path = NULL;
+ config->database_upgrades = NULL;
config->user_name = NULL;
config->user_primary_email = NULL;
config->user_other_email = NULL;
@@ -328,6 +335,10 @@ notmuch_config_open (void *ctx,
talloc_free (path);
}
+ if (notmuch_config_get_database_upgrades (config) == NULL) {
+ notmuch_config_set_database_upgrades (config, "no");
+ }
+
if (notmuch_config_get_user_name (config) == NULL) {
char *name = get_name_from_passwd_file (config);
notmuch_config_set_user_name (config, name);
@@ -582,6 +593,19 @@ notmuch_config_set_database_path (notmuch_config_t *config,
}
const char *
+notmuch_config_get_database_upgrades (notmuch_config_t *config)
+{
+ return _config_get (config, &config->database_upgrades, "database", "upgrades");
+}
+
+void
+notmuch_config_set_database_upgrades (notmuch_config_t *config,
+ const char *database_upgrades)
+{
+ _config_set (config, &config->database_upgrades, "database", "upgrades", database_upgrades);
+}
+
+const char *
notmuch_config_get_user_name (notmuch_config_t *config)
{
return _config_get (config, &config->user_name, "user", "name");
diff --git a/test/T030-config.sh b/test/T030-config.sh
index ca4cf33..d095f0e 100755
--- a/test/T030-config.sh
+++ b/test/T030-config.sh
@@ -47,6 +47,7 @@ notmuch config set database.path "/canonical/path"
output=$(notmuch config list)
test_expect_equal "$output" "\
database.path=/canonical/path
+database.upgrades=no
user.name=Notmuch Test Suite
user.primary_email=test_suite@notmuchmail.org
user.other_email=test_suite_other@notmuchmail.org;test_suite@otherdomain.org
diff --git a/test/T040-setup.sh b/test/T040-setup.sh
index 124ef1c..46fd327 100755
--- a/test/T040-setup.sh
+++ b/test/T040-setup.sh
@@ -16,6 +16,7 @@ EOF
output=$(notmuch --config=new-notmuch-config config list)
test_expect_equal "$output" "\
database.path=/path/to/maildir
+database.upgrades=no
user.name=Test Suite
user.primary_email=test.suite@example.com
user.other_email=another.suite@example.com;
--
1.9.0
next prev parent reply other threads:[~2014-03-23 2:26 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-09 15:01 WARNING: database upgrade coming David Bremner
2014-03-12 11:25 ` David Bremner
2014-03-17 17:17 ` Jameson Graef Rollins
2014-03-17 19:12 ` Jani Nikula
2014-03-17 21:19 ` David Bremner
2014-03-17 21:29 ` Jameson Graef Rollins
2014-03-23 2:26 ` conservative database upgrade control David Bremner
2014-03-23 2:26 ` David Bremner [this message]
2014-03-23 13:12 ` [PATCH 1/2] config: add key database.upgrades Jani Nikula
2014-03-23 2:26 ` [PATCH 2/2] notmuch-new: block database upgrades in default configuration David Bremner
2014-03-23 14:17 ` Jani Nikula
2014-03-23 14:35 ` David Bremner
2014-03-23 14:39 ` David Bremner
2014-03-23 23:54 ` Jameson Graef Rollins
2014-03-17 21:31 ` WARNING: database upgrade coming Jani Nikula
2014-03-18 6:06 ` Rob Browning
2014-03-18 6:57 ` Tomi Ollila
2014-03-18 11:55 ` Stewart Smith
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1395541573-2417-2-git-send-email-david@tethera.net \
--to=david@tethera.net \
--cc=notmuch@notmuchmail.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).