Re: [PATCH v4 10/16] Add n_d_add_message_with_indexopts (extension of n_d_add_message)
[notmuch-archives.git] / e0 / 477d5efc0ba6dde4e3d4649c43172a21541faf
1 Return-Path: <amthrax@drake.mit.edu>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id 7EB17431FBF\r
6         for <notmuch@notmuchmail.org>; Sun, 22 Apr 2012 08:50:59 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.7\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
12         tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id CcgLaaed1bKJ for <notmuch@notmuchmail.org>;\r
16         Sun, 22 Apr 2012 08:50:58 -0700 (PDT)\r
17 Received: from dmz-mailsec-scanner-2.mit.edu (DMZ-MAILSEC-SCANNER-2.MIT.EDU\r
18         [18.9.25.13])\r
19         by olra.theworths.org (Postfix) with ESMTP id 47842431FB6\r
20         for <notmuch@notmuchmail.org>; Sun, 22 Apr 2012 08:50:58 -0700 (PDT)\r
21 X-AuditID: 1209190d-b7fbf6d0000008ba-9c-4f9428e18a83\r
22 Received: from mailhub-auth-2.mit.edu ( [18.7.62.36])\r
23         by dmz-mailsec-scanner-2.mit.edu (Symantec Messaging Gateway) with SMTP\r
24         id CE.83.02234.1E8249F4; Sun, 22 Apr 2012 11:50:57 -0400 (EDT)\r
25 Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])\r
26         by mailhub-auth-2.mit.edu (8.13.8/8.9.2) with ESMTP id q3MFov2T024461; \r
27         Sun, 22 Apr 2012 11:50:57 -0400\r
28 Received: from drake.mit.edu\r
29         (209-6-116-242.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com\r
30         [209.6.116.242]) (authenticated bits=0)\r
31         (User authenticated as amdragon@ATHENA.MIT.EDU)\r
32         by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q3MFou7c003692\r
33         (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
34         Sun, 22 Apr 2012 11:50:57 -0400 (EDT)\r
35 Received: from amthrax by drake.mit.edu with local (Exim 4.77)\r
36         (envelope-from <amthrax@drake.mit.edu>)\r
37         id 1SLz3w-0002fB-B0; Sun, 22 Apr 2012 11:50:56 -0400\r
38 From: Austin Clements <amdragon@MIT.EDU>\r
39 To: notmuch@notmuchmail.org\r
40 Subject: [PATCH v3 1/4] new: Consistently treat fatal errors as fatal\r
41 Date: Sun, 22 Apr 2012 11:50:49 -0400\r
42 Message-Id: <1335109852-10150-2-git-send-email-amdragon@mit.edu>\r
43 X-Mailer: git-send-email 1.7.9.1\r
44 In-Reply-To: <1335109852-10150-1-git-send-email-amdragon@mit.edu>\r
45 References: <1330357759-1337-1-git-send-email-amdragon@mit.edu>\r
46         <1335109852-10150-1-git-send-email-amdragon@mit.edu>\r
47 X-Brightmail-Tracker:\r
48  H4sIAAAAAAAAA+NgFtrEIsWRmVeSWpSXmKPExsUixG6novtQY4q/waJJxhbXb85kdmD0eLbq\r
49         FnMAYxSXTUpqTmZZapG+XQJXRuuJE8wF0wUrJk9uYWlg3MrbxcjJISFgIjF34RsmCFtM4sK9\r
50         9WxdjFwcQgL7GCX+zzrDBpIQEtjAKLHvnQFE4j6TxPrvE5kgnPmMEjfuTQBrZxPQkNi2fzkj\r
51         iC0iIC2x8+5s1i5GDg5mATWJP10qIGFhAVeJht6XrCA2i4CqRM//yWDlvAIOEsvutbFDXKEg\r
52         8WzdcbCRnAKOEh/frWSCOKJM4tu8t+wTGPkXMDKsYpRNya3SzU3MzClOTdYtTk7My0st0jXS\r
53         y80s0UtNKd3ECAoaTkneHYzvDiodYhTgYFTi4X1pMtlfiDWxrLgy9xCjJAeTkiivm9oUfyG+\r
54         pPyUyozE4oz4otKc1OJDjBIczEoivJ9FgMp5UxIrq1KL8mFS0hwsSuK8qlrv/IQE0hNLUrNT\r
55         UwtSi2CyMhwcShK85sDoEBIsSk1PrUjLzClBSDNxcIIM5wEabg1Sw1tckJhbnJkOkT/FqCgl\r
56         zqsMkhAASWSU5sH1wqL6FaM40CvCvCEgVTzAhADX/QpoMBPQ4ISYSSCDSxIRUlINjPK3Njru\r
57         92x4Yu0xzTak+ovBPKm2KOslBy6t9hXunJJz9fJ0ya99O1u43PTZz74y4Dze/pWpXnC1XxmX\r
58         w7OSl5ob5r4qaLpvsu7hZo3zAmv6ptq+3/hTtO3WgcXRGqwPmk9N28dxuVqxTuZPe/wNXbsz\r
59         Quds/6xLYI69oLZb6N3kAEtR36L3V5VYijMSDbWYi4oTAXVTbufFAgAA\r
60 X-BeenThere: notmuch@notmuchmail.org\r
61 X-Mailman-Version: 2.1.13\r
62 Precedence: list\r
63 List-Id: "Use and development of the notmuch mail system."\r
64         <notmuch.notmuchmail.org>\r
65 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
66         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
67 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
68 List-Post: <mailto:notmuch@notmuchmail.org>\r
69 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
70 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
71         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
72 X-List-Received-Date: Sun, 22 Apr 2012 15:50:59 -0000\r
73 \r
74 Previously, fatal errors in add_files_recursive were not treated as\r
75 fatal by its callers (including itself!).  This makes\r
76 add_files_recursive errors consistently fatal and updates all callers\r
77 to treat them as fatal.\r
78 ---\r
79  notmuch-new.c |   16 ++++++++++++----\r
80  1 files changed, 12 insertions(+), 4 deletions(-)\r
81 \r
82 diff --git a/notmuch-new.c b/notmuch-new.c\r
83 index 4f13535..15c0b36 100644\r
84 --- a/notmuch-new.c\r
85 +++ b/notmuch-new.c\r
86 @@ -308,6 +308,10 @@ add_files_recursive (notmuch_database_t *notmuch,\r
87      if (num_fs_entries == -1) {\r
88         fprintf (stderr, "Error opening directory %s: %s\n",\r
89                  path, strerror (errno));\r
90 +       /* We consider this a fatal error because, if a user moved a\r
91 +        * message from another directory that we were able to scan\r
92 +        * into this directory, skipping this directory will cause\r
93 +        * that message to be lost. */\r
94         ret = NOTMUCH_STATUS_FILE_ERROR;\r
95         goto DONE;\r
96      }\r
97 @@ -351,8 +355,10 @@ add_files_recursive (notmuch_database_t *notmuch,\r
98  \r
99         next = talloc_asprintf (notmuch, "%s/%s", path, entry->d_name);\r
100         status = add_files_recursive (notmuch, next, state);\r
101 -       if (status && ret == NOTMUCH_STATUS_SUCCESS)\r
102 +       if (status) {\r
103             ret = status;\r
104 +           goto DONE;\r
105 +       }\r
106         talloc_free (next);\r
107         next = NULL;\r
108      }\r
109 @@ -933,6 +939,8 @@ notmuch_new_command (void *ctx, int argc, char *argv[])\r
110      }\r
111  \r
112      ret = add_files (notmuch, db_path, &add_files_state);\r
113 +    if (ret)\r
114 +       goto DONE;\r
115  \r
116      gettimeofday (&tv_start, NULL);\r
117      for (f = add_files_state.removed_files->head; f && !interrupted; f = f->next) {\r
118 @@ -965,6 +973,7 @@ notmuch_new_command (void *ctx, int argc, char *argv[])\r
119         }\r
120      }\r
121  \r
122 +  DONE:\r
123      talloc_free (add_files_state.removed_files);\r
124      talloc_free (add_files_state.removed_directories);\r
125      talloc_free (add_files_state.directory_mtimes);\r
126 @@ -1012,10 +1021,9 @@ notmuch_new_command (void *ctx, int argc, char *argv[])\r
127  \r
128      printf ("\n");\r
129  \r
130 -    if (ret) {\r
131 -       printf ("\nNote: At least one error was encountered: %s\n",\r
132 +    if (ret)\r
133 +       printf ("\nNote: A fatal error was encountered: %s\n",\r
134                 notmuch_status_to_string (ret));\r
135 -    }\r
136  \r
137      notmuch_database_close (notmuch);\r
138  \r
139 -- \r
140 1.7.9.1\r
141 \r