[PATCH 2/2] notmuch-new: block database upgrades in default configuration.

Jani Nikula jani at nikula.org
Sun Mar 23 07:17:38 PDT 2014


On Sun, 23 Mar 2014, David Bremner <david at tethera.net> wrote:
> 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");

"and if you're paranoid, please switch off the same option afterwards"?

We really have very few configuration options, and so far none of them
are such that we could make the decision for the user. I think in this
case pushing the responsibility to the user would be just *us* being
paranoid. What does that tell our users?

I also think the user should consider doing backups before upgrading
notmuch in the first place. I am generally more concerned about the user
doing a database dump of the old database version using the new notmuch
than doing the upgrade. (Although in this case I think we're fine unless
the user decides 'notmuch dump folder:important' is enough.)

BR,
Jani.


> +
> +		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
>
> _______________________________________________
> notmuch mailing list
> notmuch at notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch


More information about the notmuch mailing list