Re: [PATCH v3] nmbug: Translate to Python
[notmuch-archives.git] / 14 / cd44fc5da656b52c1d2075886d6f909dd027b1
1 Return-Path: <m.walters@qmul.ac.uk>\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 615A3431FAF\r
6         for <notmuch@notmuchmail.org>; Sun, 22 Apr 2012 00:33:58 -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: -1.098\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-1.098 tagged_above=-999 required=5\r
12         tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001,\r
13         NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3] autolearn=disabled\r
14 Received: from olra.theworths.org ([127.0.0.1])\r
15         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
16         with ESMTP id ScPhPYGZf3zO for <notmuch@notmuchmail.org>;\r
17         Sun, 22 Apr 2012 00:33:56 -0700 (PDT)\r
18 Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6])\r
19         (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
20         (No client certificate requested)\r
21         by olra.theworths.org (Postfix) with ESMTPS id ECD98431FAE\r
22         for <notmuch@notmuchmail.org>; Sun, 22 Apr 2012 00:33:55 -0700 (PDT)\r
23 Received: from smtp.qmul.ac.uk ([138.37.6.40])\r
24         by mail2.qmul.ac.uk with esmtp (Exim 4.71)\r
25         (envelope-from <m.walters@qmul.ac.uk>)\r
26         id 1SLrIq-00021L-Gq; Sun, 22 Apr 2012 08:33:51 +0100\r
27 Received: from 94-192-233-223.zone6.bethere.co.uk ([94.192.233.223]\r
28         helo=localhost)\r
29         by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.69)\r
30         (envelope-from <m.walters@qmul.ac.uk>)\r
31         id 1SLrIq-0007ge-5N; Sun, 22 Apr 2012 08:33:48 +0100\r
32 From: Mark Walters <markwalters1009@gmail.com>\r
33 To: Austin Clements <amdragon@MIT.EDU>, notmuch@notmuchmail.org\r
34 Subject: Re: [PATCH v2 2/4] new: Handle fatal errors in remove_filename and\r
35         _remove_directory\r
36 In-Reply-To: <1335068868-12593-3-git-send-email-amdragon@mit.edu>\r
37 References: <1330357759-1337-1-git-send-email-amdragon@mit.edu>\r
38         <1335068868-12593-1-git-send-email-amdragon@mit.edu>\r
39         <1335068868-12593-3-git-send-email-amdragon@mit.edu>\r
40 User-Agent: Notmuch/0.12+110~gbc97b4a (http://notmuchmail.org) Emacs/23.3.1\r
41         (x86_64-pc-linux-gnu)\r
42 Date: Sun, 22 Apr 2012 08:34:07 +0100\r
43 Message-ID: <87aa24kyog.fsf@qmul.ac.uk>\r
44 MIME-Version: 1.0\r
45 Content-Type: text/plain; charset=us-ascii\r
46 X-Sender-Host-Address: 94.192.233.223\r
47 X-QM-SPAM-Info: Sender has good ham record.  :)\r
48 X-QM-Body-MD5: 7a29a6c86919913d8a1e5551ff7ee55e (of first 20000 bytes)\r
49 X-SpamAssassin-Score: -1.8\r
50 X-SpamAssassin-SpamBar: -\r
51 X-SpamAssassin-Report: The QM spam filters have analysed this message to\r
52         determine if it is\r
53         spam. We require at least 5.0 points to mark a message as spam.\r
54         This message scored -1.8 points.\r
55         Summary of the scoring: \r
56         * -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/,\r
57         *      medium trust\r
58         *      [138.37.6.40 listed in list.dnswl.org]\r
59         * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail\r
60         provider *      (markwalters1009[at]gmail.com)\r
61         * -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay\r
62         *      domain\r
63         *  0.5 AWL AWL: From: address is in the auto white-list\r
64 X-QM-Scan-Virus: ClamAV says the message is clean\r
65 X-BeenThere: notmuch@notmuchmail.org\r
66 X-Mailman-Version: 2.1.13\r
67 Precedence: list\r
68 List-Id: "Use and development of the notmuch mail system."\r
69         <notmuch.notmuchmail.org>\r
70 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
71         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
72 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
73 List-Post: <mailto:notmuch@notmuchmail.org>\r
74 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
75 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
76         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
77 X-List-Received-Date: Sun, 22 Apr 2012 07:33:58 -0000\r
78 \r
79 On Sun, 22 Apr 2012, Austin Clements <amdragon@MIT.EDU> wrote:\r
80 > Previously such errors were simply ignored.  Now they cause an\r
81 > immediate cleanup and abort.\r
82 > ---\r
83 >  notmuch-new.c |   25 +++++++++++++++++++------\r
84 >  1 files changed, 19 insertions(+), 6 deletions(-)\r
85 >\r
86 > diff --git a/notmuch-new.c b/notmuch-new.c\r
87 > index 15c0b36..92e0489 100644\r
88 > --- a/notmuch-new.c\r
89 > +++ b/notmuch-new.c\r
90 > @@ -785,8 +785,10 @@ remove_filename (notmuch_database_t *notmuch,\r
91 >       add_files_state->renamed_messages++;\r
92 >       if (add_files_state->synchronize_flags == TRUE)\r
93 >           notmuch_message_maildir_flags_to_tags (message);\r
94 > -    } else\r
95 > +     status = NOTMUCH_STATUS_SUCCESS;\r
96 > +    } else if (status == NOTMUCH_STATUS_SUCCESS) {\r
97 >       add_files_state->removed_messages++;\r
98 > +    }\r
99 >      notmuch_message_destroy (message);\r
100 >      notmuch_database_end_atomic (notmuch);\r
101 >      return status;\r
102 > @@ -794,12 +796,13 @@ remove_filename (notmuch_database_t *notmuch,\r
103 >  \r
104 >  /* Recursively remove all filenames from the database referring to\r
105 >   * 'path' (or to any of its children). */\r
106 > -static void\r
107 > +static notmuch_status_t\r
108 >  _remove_directory (void *ctx,\r
109 >                  notmuch_database_t *notmuch,\r
110 >                  const char *path,\r
111 >                  add_files_state_t *add_files_state)\r
112 >  {\r
113 > +    notmuch_status_t status = NOTMUCH_STATUS_SUCCESS;\r
114 >      notmuch_directory_t *directory;\r
115 >      notmuch_filenames_t *files, *subdirs;\r
116 >      char *absolute;\r
117 > @@ -812,8 +815,10 @@ _remove_directory (void *ctx,\r
118 >      {\r
119 >       absolute = talloc_asprintf (ctx, "%s/%s", path,\r
120 >                                   notmuch_filenames_get (files));\r
121 > -     remove_filename (notmuch, absolute, add_files_state);\r
122 > +     status = remove_filename (notmuch, absolute, add_files_state);\r
123 >       talloc_free (absolute);\r
124 > +     if (status)\r
125 > +         goto DONE;\r
126 >      }\r
127 >  \r
128 >      for (subdirs = notmuch_directory_get_child_directories (directory);\r
129 > @@ -822,11 +827,15 @@ _remove_directory (void *ctx,\r
130 >      {\r
131 >       absolute = talloc_asprintf (ctx, "%s/%s", path,\r
132 >                                   notmuch_filenames_get (subdirs));\r
133 > -     _remove_directory (ctx, notmuch, absolute, add_files_state);\r
134 > +     status = _remove_directory (ctx, notmuch, absolute, add_files_state);\r
135 >       talloc_free (absolute);\r
136 > +     if (status)\r
137 > +         goto DONE;\r
138 >      }\r
139 >  \r
140 > +  DONE:\r
141 >      notmuch_directory_destroy (directory);\r
142 > +    return NOTMUCH_STATUS_SUCCESS;\r
143 \r
144 Doesn't this need to be return status or something?\r
145 \r
146 Best wishes\r
147 \r
148 Mark\r
149 \r
150 \r
151 >  }\r
152 >  \r
153 >  int\r
154 > @@ -944,7 +953,9 @@ notmuch_new_command (void *ctx, int argc, char *argv[])\r
155 >  \r
156 >      gettimeofday (&tv_start, NULL);\r
157 >      for (f = add_files_state.removed_files->head; f && !interrupted; f = f->next) {\r
158 > -     remove_filename (notmuch, f->filename, &add_files_state);\r
159 > +     ret = remove_filename (notmuch, f->filename, &add_files_state);\r
160 > +     if (ret)\r
161 > +         goto DONE;\r
162 >       if (do_print_progress) {\r
163 >           do_print_progress = 0;\r
164 >           generic_print_progress ("Cleaned up", "messages",\r
165 > @@ -955,7 +966,9 @@ notmuch_new_command (void *ctx, int argc, char *argv[])\r
166 >  \r
167 >      gettimeofday (&tv_start, NULL);\r
168 >      for (f = add_files_state.removed_directories->head, i = 0; f && !interrupted; f = f->next, i++) {\r
169 > -     _remove_directory (ctx, notmuch, f->filename, &add_files_state);\r
170 > +     ret = _remove_directory (ctx, notmuch, f->filename, &add_files_state);\r
171 > +     if (ret)\r
172 > +         goto DONE;\r
173 >       if (do_print_progress) {\r
174 >           do_print_progress = 0;\r
175 >           generic_print_progress ("Cleaned up", "directories",\r
176 > -- \r
177 > 1.7.9.1\r
178 >\r
179 > _______________________________________________\r
180 > notmuch mailing list\r
181 > notmuch@notmuchmail.org\r
182 > http://notmuchmail.org/mailman/listinfo/notmuch\r