[PATCH v2] new: Report and abort on upgrade failure
authorAustin Clements <amdragon@MIT.EDU>
Tue, 5 Aug 2014 14:33:43 +0000 (10:33 +2000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 18:04:07 +0000 (10:04 -0800)
99/0b34361648ce8bcab6ec0e2a85c42a7fcb5f3f [new file with mode: 0644]

diff --git a/99/0b34361648ce8bcab6ec0e2a85c42a7fcb5f3f b/99/0b34361648ce8bcab6ec0e2a85c42a7fcb5f3f
new file mode 100644 (file)
index 0000000..dc48b7c
--- /dev/null
@@ -0,0 +1,128 @@
+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 360D3431FBC\r
+       for <notmuch@notmuchmail.org>; Tue,  5 Aug 2014 07:33:57 -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 oRGZpN2yYPfg for <notmuch@notmuchmail.org>;\r
+       Tue,  5 Aug 2014 07:33:52 -0700 (PDT)\r
+Received: from dmz-mailsec-scanner-5.mit.edu (dmz-mailsec-scanner-5.mit.edu\r
+       [18.7.68.34])\r
+       by olra.theworths.org (Postfix) with ESMTP id 59C74431FAE\r
+       for <notmuch@notmuchmail.org>; Tue,  5 Aug 2014 07:33:52 -0700 (PDT)\r
+X-AuditID: 12074422-f79be6d000007518-24-53e0eb4fbc4b\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-5.mit.edu (Symantec Messaging Gateway) with SMTP\r
+       id C9.62.29976.F4BE0E35; Tue,  5 Aug 2014 10:33:51 -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 s75EXmea012535; \r
+       Tue, 5 Aug 2014 10:33:49 -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 s75EXkWZ028467\r
+       (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
+       Tue, 5 Aug 2014 10:33:48 -0400\r
+Received: from amthrax by drake.dyndns.org with local (Exim 4.77)\r
+       (envelope-from <amdragon@mit.edu>)\r
+       id 1XEfoA-0003Mj-GT; Tue, 05 Aug 2014 10:33:46 -0400\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v2] new: Report and abort on upgrade failure\r
+Date: Tue,  5 Aug 2014 10:33:43 -0400\r
+Message-Id: <1407249223-12827-1-git-send-email-amdragon@mit.edu>\r
+X-Mailer: git-send-email 2.0.0\r
+In-Reply-To: <87bnrzfau4.fsf@maritornes.cs.unb.ca>\r
+References: <87bnrzfau4.fsf@maritornes.cs.unb.ca>\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFtrDIsWRmVeSWpSXmKPExsUixCmqrOv/+kGwQVOjqcWN1m5Gi+s3ZzI7\r
+       MHk8W3WL2WPLoffMAUxRXDYpqTmZZalF+nYJXBlNfRdYCmYIVKy8eYC5gbGVt4uRk0NCwETi\r
+       6Oa17BC2mMSFe+vZQGwhgdlMEh//mXcxcgHZGxglLhx9zASRuM0ksfxbCURiLqPElDtfwLrZ\r
+       BDQktu1fzghiiwhIS+y8O5sVxGYWsJS4+rUdrFlYwEbiwt7nYBtYBFQl7k7cAxbnFXCQ+PX+\r
+       LSPEFXISDTc+gdVwChhJbD+/iQVisaHE6RfTWCYw8i9gZFjFKJuSW6Wbm5iZU5yarFucnJiX\r
+       l1qka6qXm1mil5pSuokRFEjsLko7GH8eVDrEKMDBqMTDK6B2P1iINbGsuDL3EKMkB5OSKO/S\r
+       Vw+ChfiS8lMqMxKLM+KLSnNSiw8xSnAwK4nwst8GyvGmJFZWpRblw6SkOViUxHnfWlsFCwmk\r
+       J5akZqemFqQWwWRlODiUJHijQIYKFqWmp1akZeaUIKSZODhBhvMADZ8LUsNbXJCYW5yZDpE/\r
+       xagoJc7b/RIoIQCSyCjNg+uFRforRnGgV4R5l4O08wCTBFz3K6DBTECDzXTugwwuSURISTUw\r
+       Guk+OLT1ldrBlLf+SxsS1SXydzNtLHd7ECx8r+3knkTLhLu2qx54B0/VYF5Wr+u+iHe/47EC\r
+       6YK/Ezs2Ju9eb/vWKDpvkX4Lg/nsN8yXIvU5L2xZUntccqbCr3crclKvvLRu/Z8jxBW5+/D8\r
+       eUwLJVdfv1O0Z88ph6VL1P4JfYz3tDnPnCQ5S4mlOCPRUIu5qDgRAK1i64DPAgAA\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 14:33:57 -0000\r
+\r
+Previously the return status of notmuch_database_upgrade went\r
+completely unchecked.\r
+---\r
+\r
+Quite right.  v1 had some context that had been modified by my\r
+features branch.  Here's the same patch, but with context that should\r
+work on master.\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 d269c7c..5691005 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 to database format version %u.\n",\r
+                   notmuch_database_get_version (notmuch));\r
+@@ -1091,7 +1099,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