[PATCH v3 1/4] new: Consistently treat fatal errors as fatal
authorAustin Clements <amdragon@MIT.EDU>
Sun, 22 Apr 2012 15:50:49 +0000 (11:50 +2000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:46:38 +0000 (09:46 -0800)
e0/477d5efc0ba6dde4e3d4649c43172a21541faf [new file with mode: 0644]

diff --git a/e0/477d5efc0ba6dde4e3d4649c43172a21541faf b/e0/477d5efc0ba6dde4e3d4649c43172a21541faf
new file mode 100644 (file)
index 0000000..f98c7c2
--- /dev/null
@@ -0,0 +1,141 @@
+Return-Path: <amthrax@drake.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 7EB17431FBF\r
+       for <notmuch@notmuchmail.org>; Sun, 22 Apr 2012 08:50:59 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+       tests=[RCVD_IN_DNSWL_LOW=-0.7] 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 CcgLaaed1bKJ for <notmuch@notmuchmail.org>;\r
+       Sun, 22 Apr 2012 08:50:58 -0700 (PDT)\r
+Received: from dmz-mailsec-scanner-2.mit.edu (DMZ-MAILSEC-SCANNER-2.MIT.EDU\r
+       [18.9.25.13])\r
+       by olra.theworths.org (Postfix) with ESMTP id 47842431FB6\r
+       for <notmuch@notmuchmail.org>; Sun, 22 Apr 2012 08:50:58 -0700 (PDT)\r
+X-AuditID: 1209190d-b7fbf6d0000008ba-9c-4f9428e18a83\r
+Received: from mailhub-auth-2.mit.edu ( [18.7.62.36])\r
+       by dmz-mailsec-scanner-2.mit.edu (Symantec Messaging Gateway) with SMTP\r
+       id CE.83.02234.1E8249F4; Sun, 22 Apr 2012 11:50:57 -0400 (EDT)\r
+Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])\r
+       by mailhub-auth-2.mit.edu (8.13.8/8.9.2) with ESMTP id q3MFov2T024461; \r
+       Sun, 22 Apr 2012 11:50:57 -0400\r
+Received: from drake.mit.edu\r
+       (209-6-116-242.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com\r
+       [209.6.116.242]) (authenticated bits=0)\r
+       (User authenticated as amdragon@ATHENA.MIT.EDU)\r
+       by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q3MFou7c003692\r
+       (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
+       Sun, 22 Apr 2012 11:50:57 -0400 (EDT)\r
+Received: from amthrax by drake.mit.edu with local (Exim 4.77)\r
+       (envelope-from <amthrax@drake.mit.edu>)\r
+       id 1SLz3w-0002fB-B0; Sun, 22 Apr 2012 11:50:56 -0400\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v3 1/4] new: Consistently treat fatal errors as fatal\r
+Date: Sun, 22 Apr 2012 11:50:49 -0400\r
+Message-Id: <1335109852-10150-2-git-send-email-amdragon@mit.edu>\r
+X-Mailer: git-send-email 1.7.9.1\r
+In-Reply-To: <1335109852-10150-1-git-send-email-amdragon@mit.edu>\r
+References: <1330357759-1337-1-git-send-email-amdragon@mit.edu>\r
+       <1335109852-10150-1-git-send-email-amdragon@mit.edu>\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFtrEIsWRmVeSWpSXmKPExsUixG6novtQY4q/waJJxhbXb85kdmD0eLbq\r
+       FnMAYxSXTUpqTmZZapG+XQJXRuuJE8wF0wUrJk9uYWlg3MrbxcjJISFgIjF34RsmCFtM4sK9\r
+       9WxdjFwcQgL7GCX+zzrDBpIQEtjAKLHvnQFE4j6TxPrvE5kgnPmMEjfuTQBrZxPQkNi2fzkj\r
+       iC0iIC2x8+5s1i5GDg5mATWJP10qIGFhAVeJht6XrCA2i4CqRM//yWDlvAIOEsvutbFDXKEg\r
+       8WzdcbCRnAKOEh/frWSCOKJM4tu8t+wTGPkXMDKsYpRNya3SzU3MzClOTdYtTk7My0st0jXS\r
+       y80s0UtNKd3ECAoaTkneHYzvDiodYhTgYFTi4X1pMtlfiDWxrLgy9xCjJAeTkiivm9oUfyG+\r
+       pPyUyozE4oz4otKc1OJDjBIczEoivJ9FgMp5UxIrq1KL8mFS0hwsSuK8qlrv/IQE0hNLUrNT\r
+       UwtSi2CyMhwcShK85sDoEBIsSk1PrUjLzClBSDNxcIIM5wEabg1Sw1tckJhbnJkOkT/FqCgl\r
+       zqsMkhAASWSU5sH1wqL6FaM40CvCvCEgVTzAhADX/QpoMBPQ4ISYSSCDSxIRUlINjPK3Njru\r
+       92x4Yu0xzTak+ovBPKm2KOslBy6t9hXunJJz9fJ0ya99O1u43PTZz74y4Dze/pWpXnC1XxmX\r
+       w7OSl5ob5r4qaLpvsu7hZo3zAmv6ptq+3/hTtO3WgcXRGqwPmk9N28dxuVqxTuZPe/wNXbsz\r
+       Quds/6xLYI69oLZb6N3kAEtR36L3V5VYijMSDbWYi4oTAXVTbufFAgAA\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: Sun, 22 Apr 2012 15:50:59 -0000\r
+\r
+Previously, fatal errors in add_files_recursive were not treated as\r
+fatal by its callers (including itself!).  This makes\r
+add_files_recursive errors consistently fatal and updates all callers\r
+to treat them as fatal.\r
+---\r
+ notmuch-new.c |   16 ++++++++++++----\r
+ 1 files changed, 12 insertions(+), 4 deletions(-)\r
+\r
+diff --git a/notmuch-new.c b/notmuch-new.c\r
+index 4f13535..15c0b36 100644\r
+--- a/notmuch-new.c\r
++++ b/notmuch-new.c\r
+@@ -308,6 +308,10 @@ add_files_recursive (notmuch_database_t *notmuch,\r
+     if (num_fs_entries == -1) {\r
+       fprintf (stderr, "Error opening directory %s: %s\n",\r
+                path, strerror (errno));\r
++      /* We consider this a fatal error because, if a user moved a\r
++       * message from another directory that we were able to scan\r
++       * into this directory, skipping this directory will cause\r
++       * that message to be lost. */\r
+       ret = NOTMUCH_STATUS_FILE_ERROR;\r
+       goto DONE;\r
+     }\r
+@@ -351,8 +355,10 @@ add_files_recursive (notmuch_database_t *notmuch,\r
\r
+       next = talloc_asprintf (notmuch, "%s/%s", path, entry->d_name);\r
+       status = add_files_recursive (notmuch, next, state);\r
+-      if (status && ret == NOTMUCH_STATUS_SUCCESS)\r
++      if (status) {\r
+           ret = status;\r
++          goto DONE;\r
++      }\r
+       talloc_free (next);\r
+       next = NULL;\r
+     }\r
+@@ -933,6 +939,8 @@ notmuch_new_command (void *ctx, int argc, char *argv[])\r
+     }\r
\r
+     ret = add_files (notmuch, db_path, &add_files_state);\r
++    if (ret)\r
++      goto DONE;\r
\r
+     gettimeofday (&tv_start, NULL);\r
+     for (f = add_files_state.removed_files->head; f && !interrupted; f = f->next) {\r
+@@ -965,6 +973,7 @@ notmuch_new_command (void *ctx, int argc, char *argv[])\r
+       }\r
+     }\r
\r
++  DONE:\r
+     talloc_free (add_files_state.removed_files);\r
+     talloc_free (add_files_state.removed_directories);\r
+     talloc_free (add_files_state.directory_mtimes);\r
+@@ -1012,10 +1021,9 @@ notmuch_new_command (void *ctx, int argc, char *argv[])\r
\r
+     printf ("\n");\r
\r
+-    if (ret) {\r
+-      printf ("\nNote: At least one error was encountered: %s\n",\r
++    if (ret)\r
++      printf ("\nNote: A fatal error was encountered: %s\n",\r
+               notmuch_status_to_string (ret));\r
+-    }\r
\r
+     notmuch_database_close (notmuch);\r
\r
+-- \r
+1.7.9.1\r
+\r