--- /dev/null
+Return-Path: <amdragon@mit.edu>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by olra.theworths.org (Postfix) with ESMTP id 166DE431FC0\r
+ for <notmuch@notmuchmail.org>; Mon, 4 Aug 2014 18:29:59 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -2.3\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-2.3 tagged_above=-999 required=5\r
+ tests=[RCVD_IN_DNSWL_MED=-2.3] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+ by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id TcLH537UmaUV for <notmuch@notmuchmail.org>;\r
+ Mon, 4 Aug 2014 18:29:53 -0700 (PDT)\r
+Received: from dmz-mailsec-scanner-8.mit.edu (dmz-mailsec-scanner-8.mit.edu\r
+ [18.7.68.37])\r
+ (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id B883C431FC4\r
+ for <notmuch@notmuchmail.org>; Mon, 4 Aug 2014 18:29:53 -0700 (PDT)\r
+X-AuditID: 12074425-f79766d000006da8-55-53e03390c3e8\r
+Received: from mailhub-auth-1.mit.edu ( [18.9.21.35])\r
+ (using TLS with cipher AES256-SHA (256/256 bits))\r
+ (Client did not present a certificate)\r
+ by dmz-mailsec-scanner-8.mit.edu (Symantec Messaging Gateway) with SMTP\r
+ id 47.6A.28072.09330E35; Mon, 4 Aug 2014 21:29:52 -0400 (EDT)\r
+Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11])\r
+ by mailhub-auth-1.mit.edu (8.13.8/8.9.2) with ESMTP id s751To6X018138; \r
+ Mon, 4 Aug 2014 21:29:50 -0400\r
+Received: from drake.dyndns.org\r
+ (216-15-114-40.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com\r
+ [216.15.114.40]) (authenticated bits=0)\r
+ (User authenticated as amdragon@ATHENA.MIT.EDU)\r
+ by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id s751Tmc7000738\r
+ (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
+ Mon, 4 Aug 2014 21:29:49 -0400\r
+Received: from amthrax by drake.dyndns.org with local (Exim 4.77)\r
+ (envelope-from <amdragon@mit.edu>)\r
+ id 1XETZU-00012f-Ni; Mon, 04 Aug 2014 21:29:48 -0400\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH] new: Report and abort on upgrade failure\r
+Date: Mon, 4 Aug 2014 21:29:46 -0400\r
+Message-Id: <1407202186-3968-1-git-send-email-amdragon@mit.edu>\r
+X-Mailer: git-send-email 2.0.0\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFprFIsWRmVeSWpSXmKPExsUixCmqrDvB+EGwwemXvBbXb85kdmD0eLbq\r
+ FnMAYxSXTUpqTmZZapG+XQJXxuOL+9gLNvNVbN56kbmB8Rx3FyMnh4SAicSWX1PYIWwxiQv3\r
+ 1rN1MXJxCAnMZpKYcnUqC4SzgVHi2YYFrCBVQgK3mST+rNOFSMxllFjz/SojSIJNQENi2/7l\r
+ YLaIgLTEzruzgRo4OJgF1CT+dKmAhIUFLCX2Ni0Hm8MioCqx+/83MJtXwF7i87mdrBBXyEk0\r
+ 3PjENoGRdwEjwypG2ZTcKt3cxMyc4tRk3eLkxLy81CJdC73czBK91JTSTYygIGB3Ud3BOOGQ\r
+ 0iFGAQ5GJR5eAbX7wUKsiWXFlbmHGCU5mJREeUP1HgQL8SXlp1RmJBZnxBeV5qQWH2KU4GBW\r
+ EuHNFwTK8aYkVlalFuXDpKQ5WJTEed9aWwULCaQnlqRmp6YWpBbBZGU4OJQkeA8bAjUKFqWm\r
+ p1akZeaUIKSZODhBhvMADT8NUsNbXJCYW5yZDpE/xagoJc7rAZIQAElklObB9cKi9BWjONAr\r
+ wrwXQKp4gBEO1/0KaDAT0GAznfsgg0sSEVJSDYx72Dbp+Msli3y1Nc/zXLJH4mTxObMU61UW\r
+ HswR/wVul69IPBSQ0bH2WbTMnrjJM5KSk9T+r3LNva/Cosu7UeSd6J38ZtW/xSef750ltEqT\r
+ jbVVIC/Y7eah8yEvSn6q6Wy8vd9mfq2T49Mt8buOtjvvOe9w+Vv6g+kKsYWM/ffUeMpc51ft\r
+ jlJiKc5INNRiLipOBADy0TXSrQIAAA==\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Tue, 05 Aug 2014 01:29:59 -0000\r
+\r
+Previously the return status of notmuch_database_upgrade went\r
+completely unchecked.\r
+---\r
+ notmuch-new.c | 15 +++++++++++----\r
+ 1 file changed, 11 insertions(+), 4 deletions(-)\r
+\r
+diff --git a/notmuch-new.c b/notmuch-new.c\r
+index b7590a8..ddf42c1 100644\r
+--- a/notmuch-new.c\r
++++ b/notmuch-new.c\r
+@@ -923,6 +923,7 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[])\r
+ notmuch_bool_t timer_is_active = FALSE;\r
+ notmuch_bool_t no_hooks = FALSE;\r
+ notmuch_bool_t quiet = FALSE, verbose = FALSE;\r
++ notmuch_status_t status;\r
+ \r
+ add_files_state.verbosity = VERBOSITY_NORMAL;\r
+ add_files_state.debug = FALSE;\r
+@@ -1019,9 +1020,16 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[])\r
+ }\r
+ \r
+ gettimeofday (&add_files_state.tv_start, NULL);\r
+- notmuch_database_upgrade (notmuch,\r
+- add_files_state.verbosity >= VERBOSITY_NORMAL ? upgrade_print_progress : NULL,\r
+- &add_files_state);\r
++ status = notmuch_database_upgrade (\r
++ notmuch,\r
++ add_files_state.verbosity >= VERBOSITY_NORMAL ? upgrade_print_progress : NULL,\r
++ &add_files_state);\r
++ if (status) {\r
++ printf ("Upgrade failed: %s\n",\r
++ notmuch_status_to_string (status));\r
++ notmuch_database_destroy (notmuch);\r
++ return EXIT_FAILURE;\r
++ }\r
+ if (add_files_state.verbosity >= VERBOSITY_NORMAL)\r
+ printf ("Your notmuch database has now been upgraded.\n");\r
+ }\r
+@@ -1090,7 +1098,6 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[])\r
+ }\r
+ \r
+ for (f = add_files_state.directory_mtimes->head; f && !interrupted; f = f->next) {\r
+- notmuch_status_t status;\r
+ notmuch_directory_t *directory;\r
+ status = notmuch_database_get_directory (notmuch, f->filename, &directory);\r
+ if (status == NOTMUCH_STATUS_SUCCESS && directory) {\r
+-- \r
+2.0.0\r
+\r