[PATCH 2/2] notmuch-new: block database upgrades in default configuration.
David Bremner
david at tethera.net
Sat Mar 22 19:26:13 PDT 2014
People who prefer the current behaviour can set the configuration
variable and forget it.
---
notmuch-new.c | 9 +++++++++
test/T530-upgrade.sh | 11 +++++++++++
2 files changed, 20 insertions(+)
diff --git a/notmuch-new.c b/notmuch-new.c
index 82acf69..c6a15b0 100644
--- a/notmuch-new.c
+++ b/notmuch-new.c
@@ -989,6 +989,15 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[])
return EXIT_FAILURE;
if (notmuch_database_needs_upgrade (notmuch)) {
+ if (strcasecmp(notmuch_config_get_database_upgrades (config), "yes") != 0) {
+ fprintf (stderr,
+ "Database upgrade needed. Please enable with\n\n"
+ " notmuch config set database.upgrades yes\n\n"
+ "after taking appropriate precautions.\n");
+
+ return EXIT_FAILURE;
+ }
+
if (add_files_state.verbosity >= VERBOSITY_NORMAL)
printf ("Welcome to a new version of notmuch! Your database will now be upgraded.\n");
gettimeofday (&add_files_state.tv_start, NULL);
diff --git a/test/T530-upgrade.sh b/test/T530-upgrade.sh
index 67bbf31..00dcb1e 100755
--- a/test/T530-upgrade.sh
+++ b/test/T530-upgrade.sh
@@ -25,8 +25,19 @@ test_begin_subtest "path: search does not work with old database version"
output=$(notmuch search path:foo)
test_expect_equal "$output" ""
+test_begin_subtest "database upgrade blocked by default config"
+output=$(notmuch new 2>&1)
+test_expect_equal "$output" "\
+Database upgrade needed. Please enable with
+
+ notmuch config set database.upgrades yes
+
+after taking appropriate precautions."
+
test_begin_subtest "database upgrade from format version 1"
+notmuch config set database.upgrades yes
output=$(notmuch new)
+
test_expect_equal "$output" "\
Welcome to a new version of notmuch! Your database will now be upgraded.
Your notmuch database has now been upgraded to database format version 2.
--
1.9.0
More information about the notmuch
mailing list