From: Austin Clements Date: Sun, 22 Apr 2012 04:27:45 +0000 (+2000) Subject: [PATCH v2 1/4] new: Consistently treat fatal errors as fatal X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=a9113078f96893948a7919249fd09528a151a13e;p=notmuch-archives.git [PATCH v2 1/4] new: Consistently treat fatal errors as fatal --- diff --git a/df/2ab1a539bf2039af19403bfe23492539bf3d78 b/df/2ab1a539bf2039af19403bfe23492539bf3d78 new file mode 100644 index 000000000..a1a0020cd --- /dev/null +++ b/df/2ab1a539bf2039af19403bfe23492539bf3d78 @@ -0,0 +1,141 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id B3E84431FAF + for ; Sat, 21 Apr 2012 21:27:54 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -0.7 +X-Spam-Level: +X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 + tests=[RCVD_IN_DNSWL_LOW=-0.7] 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 5rf3vVrGw-xb for ; + Sat, 21 Apr 2012 21:27:54 -0700 (PDT) +Received: from dmz-mailsec-scanner-6.mit.edu (DMZ-MAILSEC-SCANNER-6.MIT.EDU + [18.7.68.35]) + by olra.theworths.org (Postfix) with ESMTP id 2B6FF431FAE + for ; Sat, 21 Apr 2012 21:27:54 -0700 (PDT) +X-AuditID: 12074423-b7fea6d0000074b0-f0-4f9388c9f221 +Received: from mailhub-auth-4.mit.edu ( [18.7.62.39]) + by dmz-mailsec-scanner-6.mit.edu (Symantec Messaging Gateway) with SMTP + id 1F.77.29872.9C8839F4; Sun, 22 Apr 2012 00:27:53 -0400 (EDT) +Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) + by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id q3M4Rrt1019367; + Sun, 22 Apr 2012 00:27:53 -0400 +Received: from drake.mit.edu + (209-6-116-242.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com + [209.6.116.242]) (authenticated bits=0) + (User authenticated as amdragon@ATHENA.MIT.EDU) + by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q3M4RqKI011055 + (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); + Sun, 22 Apr 2012 00:27:52 -0400 (EDT) +Received: from amthrax by drake.mit.edu with local (Exim 4.77) + (envelope-from ) + id 1SLoOu-0003I6-0p; Sun, 22 Apr 2012 00:27:52 -0400 +From: Austin Clements +To: notmuch@notmuchmail.org +Subject: [PATCH v2 1/4] new: Consistently treat fatal errors as fatal +Date: Sun, 22 Apr 2012 00:27:45 -0400 +Message-Id: <1335068868-12593-2-git-send-email-amdragon@mit.edu> +X-Mailer: git-send-email 1.7.9.1 +In-Reply-To: <1335068868-12593-1-git-send-email-amdragon@mit.edu> +References: <1330357759-1337-1-git-send-email-amdragon@mit.edu> + <1335068868-12593-1-git-send-email-amdragon@mit.edu> +X-Brightmail-Tracker: + H4sIAAAAAAAAA+NgFtrEIsWRmVeSWpSXmKPExsUixG6nrnuyY7K/waNL8hbXb85kdmD0eLbq + FnMAYxSXTUpqTmZZapG+XQJXRuuJE8wF0wUrJk9uYWlg3MrbxcjJISFgIvFnxxYmCFtM4sK9 + 9WxdjFwcQgL7GCXO9b1hgXA2MEo82vWFHcK5zySx9dh1VpAWIYH5jBJPztSD2GwCGhLb9i9n + BLFFBKQldt6dDVTDwcEsoCbxp0sFJCws4Cqx+Mx5sBIWAVWJJ+fvsoHYvAIOEmvO3WWBuEJB + 4tm642AXcQo4Six+eZwRYlWZRNPLZYwTGPkXMDKsYpRNya3SzU3MzClOTdYtTk7My0st0jXT + y80s0UtNKd3ECA4aF+UdjH8OKh1iFOBgVOLhfWUy2V+INbGsuDL3EKMkB5OSKK9+JVCILyk/ + pTIjsTgjvqg0J7X4EKMEB7OSCO9nEaAcb0piZVVqUT5MSpqDRUmcV0PrnZ+QQHpiSWp2ampB + ahFMVoaDQ0mC1wkYHUKCRanpqRVpmTklCGkmDk6Q4TxAw5+3gwwvLkjMLc5Mh8ifYlSUEucV + AWkWAElklObB9cKi+hWjONArwrxGIFU8wIQA1/0KaDAT0OCEmEkgg0sSEVJSDYxzpZYn2emm + s4dmfJy//OMnpxnnbua92lqnO7V2zi325oh3X08y3vlb+0Dh44HFpzafvXCudvJ8bU2b3XLq + JdsYF+7ardHBM//c7cDKnJCNm1avbVm82mqyCOORRF+r3brLtaeWLdibJfl+0S39tNeCrwTf + Gjv5ynE7eF1pEzfzNLonFxAcqXlTiaU4I9FQi7moOBEA1HLA08UCAAA= +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, 22 Apr 2012 04:27:54 -0000 + +Previously, fatal errors in add_files_recursive were not treated as +fatal by its callers (including itself!). This makes +add_files_recursive errors consistently fatal and updates all callers +to treat them as fatal. +--- + notmuch-new.c | 16 ++++++++++++---- + 1 files changed, 12 insertions(+), 4 deletions(-) + +diff --git a/notmuch-new.c b/notmuch-new.c +index 4f13535..15c0b36 100644 +--- a/notmuch-new.c ++++ b/notmuch-new.c +@@ -308,6 +308,10 @@ add_files_recursive (notmuch_database_t *notmuch, + if (num_fs_entries == -1) { + fprintf (stderr, "Error opening directory %s: %s\n", + path, strerror (errno)); ++ /* We consider this a fatal error because, if a user moved a ++ * message from another directory that we were able to scan ++ * into this directory, skipping this directory will cause ++ * that message to be lost. */ + ret = NOTMUCH_STATUS_FILE_ERROR; + goto DONE; + } +@@ -351,8 +355,10 @@ add_files_recursive (notmuch_database_t *notmuch, + + next = talloc_asprintf (notmuch, "%s/%s", path, entry->d_name); + status = add_files_recursive (notmuch, next, state); +- if (status && ret == NOTMUCH_STATUS_SUCCESS) ++ if (status) { + ret = status; ++ goto DONE; ++ } + talloc_free (next); + next = NULL; + } +@@ -933,6 +939,8 @@ notmuch_new_command (void *ctx, int argc, char *argv[]) + } + + ret = add_files (notmuch, db_path, &add_files_state); ++ if (ret) ++ goto DONE; + + gettimeofday (&tv_start, NULL); + for (f = add_files_state.removed_files->head; f && !interrupted; f = f->next) { +@@ -965,6 +973,7 @@ notmuch_new_command (void *ctx, int argc, char *argv[]) + } + } + ++ DONE: + talloc_free (add_files_state.removed_files); + talloc_free (add_files_state.removed_directories); + talloc_free (add_files_state.directory_mtimes); +@@ -1012,10 +1021,9 @@ notmuch_new_command (void *ctx, int argc, char *argv[]) + + printf ("\n"); + +- if (ret) { +- printf ("\nNote: At least one error was encountered: %s\n", ++ if (ret) ++ printf ("\nNote: A fatal error was encountered: %s\n", + notmuch_status_to_string (ret)); +- } + + notmuch_database_close (notmuch); + +-- +1.7.9.1 +