[PATCH 1/2] config: add key database.upgrades

David Bremner david at tethera.net
Sat Mar 22 19:26:12 PDT 2014


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 at notmuchmail.org
 user.other_email=test_suite_other at notmuchmail.org;test_suite at 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 at example.com
 user.other_email=another.suite at example.com;
-- 
1.9.0



More information about the notmuch mailing list