From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id B8816431FC0 for ; Sat, 22 Mar 2014 19:26:43 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id hYMR7G+1ocAC for ; Sat, 22 Mar 2014 19:26:38 -0700 (PDT) Received: from yantan.tethera.net (yantan.tethera.net [199.188.72.155]) (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id B9331431FC2 for ; Sat, 22 Mar 2014 19:26:37 -0700 (PDT) Received: from remotemail by yantan.tethera.net with local (Exim 4.80) (envelope-from ) id 1WRY7R-0008P9-CR; Sat, 22 Mar 2014 23:26:37 -0300 Received: (nullmailer pid 2941 invoked by uid 1000); Sun, 23 Mar 2014 02:26:26 -0000 From: David Bremner To: notmuch@notmuchmail.org Subject: [PATCH 2/2] notmuch-new: block database upgrades in default configuration. Date: Sat, 22 Mar 2014 23:26:13 -0300 Message-Id: <1395541573-2417-3-git-send-email-david@tethera.net> X-Mailer: git-send-email 1.9.0 In-Reply-To: <1395541573-2417-1-git-send-email-david@tethera.net> References: <87bnx4jyyp.fsf@servo.finestructure.net> <1395541573-2417-1-git-send-email-david@tethera.net> X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 23 Mar 2014 02:26:43 -0000 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