1 Return-Path: <jani@nikula.org>
\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 61C3D431FBF
\r
6 for <notmuch@notmuchmail.org>; Mon, 1 Apr 2013 12:38:09 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\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 ASc43MD-JSaF for <notmuch@notmuchmail.org>;
\r
16 Mon, 1 Apr 2013 12:38:07 -0700 (PDT)
\r
17 Received: from mail-lb0-f182.google.com (mail-lb0-f182.google.com
\r
18 [209.85.217.182]) (using TLSv1 with cipher RC4-SHA (128/128 bits))
\r
19 (No client certificate requested)
\r
20 by olra.theworths.org (Postfix) with ESMTPS id 07F1A431FAE
\r
21 for <notmuch@notmuchmail.org>; Mon, 1 Apr 2013 12:38:06 -0700 (PDT)
\r
22 Received: by mail-lb0-f182.google.com with SMTP id z13so2265488lbh.27
\r
23 for <notmuch@notmuchmail.org>; Mon, 01 Apr 2013 12:38:05 -0700 (PDT)
\r
24 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
\r
25 d=google.com; s=20120113;
\r
26 h=x-received:from:to:cc:subject:in-reply-to:references:user-agent
\r
27 :date:message-id:mime-version:content-type:x-gm-message-state;
\r
28 bh=3WHwMNrTInsmxWpNB0YfF9ysF7kB8VOwCYl9cIJc0Lc=;
\r
29 b=EdyUcttnlO521BjJiZFenoZnI2u+s99Co9DX/QS9dUQaP0Wtzeiqv1zQNrZKFPsfxR
\r
30 ial6vSZ4BLZjJY/2P5mYbExomzt9yBFiKrhbrQqCE4r+odHjl43Ij6eTEwAkPSLCtMzv
\r
31 xj2g/yDvQpNuB4N+Fs0E2FGff0jB9I+1StpfF6olld8DwpLqxeol6yqHTDFX0VdHrNCj
\r
32 yvAyO01hBnzVaqQSxNQclATecHbSLSRmoIuI1RPv6pimWJuWhybguKoS9D3UY7QjSVih
\r
33 QxAmd8nYfh2CrtzLwbyzzQ9okAlBgXXbs7Wpp/FGXuFYuCizqajTQYhzMBLHxzBlCims
\r
35 X-Received: by 10.112.180.105 with SMTP id dn9mr6260468lbc.10.1364845085490;
\r
36 Mon, 01 Apr 2013 12:38:05 -0700 (PDT)
\r
37 Received: from localhost (dsl-hkibrasgw4-50df51-27.dhcp.inet.fi.
\r
39 by mx.google.com with ESMTPS id c7sm2795312lbe.6.2013.04.01.12.38.03
\r
40 (version=TLSv1.2 cipher=RC4-SHA bits=128/128);
\r
41 Mon, 01 Apr 2013 12:38:04 -0700 (PDT)
\r
42 From: Jani Nikula <jani@nikula.org>
\r
43 To: Peter Wang <novalazy@gmail.com>, David Bremner <david@tethera.net>
\r
44 Subject: Re: [PATCH v4 06/12] test: add tests for insert
\r
45 In-Reply-To: <20130330150537.GA1971@hili.localdomain>
\r
46 References: <1359029288-12132-1-git-send-email-novalazy@gmail.com>
\r
47 <1359029288-12132-7-git-send-email-novalazy@gmail.com>
\r
48 <87d2uhiwoz.fsf@maritornes.cs.unb.ca>
\r
49 <20130330150537.GA1971@hili.localdomain>
\r
50 User-Agent: Notmuch/0.15.2+70~g2eeb96a (http://notmuchmail.org) Emacs/24.2.1
\r
51 (x86_64-pc-linux-gnu)
\r
52 Date: Mon, 01 Apr 2013 22:38:02 +0300
\r
53 Message-ID: <87wqsmnisl.fsf@nikula.org>
\r
55 Content-Type: text/plain
\r
57 ALoCoQlG3y/LzKPrOUx5eu5Eheunc1ZyNPZt0hywh8mdI2jCBO4/NDGyGpTUSc2BmYX4zUViBfzc
\r
58 Cc: notmuch@notmuchmail.org
\r
59 X-BeenThere: notmuch@notmuchmail.org
\r
60 X-Mailman-Version: 2.1.13
\r
62 List-Id: "Use and development of the notmuch mail system."
\r
63 <notmuch.notmuchmail.org>
\r
64 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
65 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
66 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
67 List-Post: <mailto:notmuch@notmuchmail.org>
\r
68 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
69 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
70 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
71 X-List-Received-Date: Mon, 01 Apr 2013 19:38:09 -0000
\r
73 On Sat, 30 Mar 2013, Peter Wang <novalazy@gmail.com> wrote:
\r
74 > On Fri, 29 Mar 2013 19:59:56 -0400, David Bremner <david@tethera.net> wrote:
\r
76 >> It took longer than I thought (of course) but I finally finished looking
\r
77 >> at the first 6 patches.
\r
79 >> I already mentioned a minor man page issue in a seperate message.
\r
81 >> I took a second pass through 03/12, and I think I would prefer thethe
\r
82 >> control flow of insert_message be closer to the standard style in
\r
83 >> notmuch of using a return value variable and a single cleanup block at
\r
84 >> the end. Reasonable people can disagree about issues of style, but in
\r
85 >> the end consistency of the code base is also important.
\r
87 I think sync_dir() was worse than insert_message() in this regard.
\r
92 > static notmuch_bool_t
\r
93 > insert_message (void *ctx, notmuch_database_t *notmuch, int fdin,
\r
94 > const char *dir, tag_op_list_t *tag_ops)
\r
100 > char *cleanup_path;
\r
102 > fdout = maildir_open_tmp_file (ctx, dir, &tmppath, &newpath, &newdir);
\r
106 > cleanup_path = tmppath;
\r
108 > if (! copy_stdin (fdin, fdout))
\r
111 > if (fsync (fdout) != 0) {
\r
112 > fprintf (stderr, "Error: fsync failed: %s\n", strerror (errno));
\r
119 > /* Atomically move the new message file from the Maildir 'tmp' directory
\r
120 > * to the 'new' directory. We follow the Dovecot recommendation to
\r
121 > * simply use rename() instead of link() and unlink().
\r
122 > * See also: http://wiki.dovecot.org/MailboxFormat/Maildir#Mail_delivery
\r
124 > if (rename (tmppath, newpath) != 0) {
\r
125 > fprintf (stderr, "Error: rename() failed: %s\n", strerror (errno));
\r
129 > cleanup_path = newpath;
\r
131 > if (! add_file_to_database (notmuch, newpath, tag_ops)) {
\r
132 > /* XXX add an option to keep the file in maildir? */
\r
136 > if (! sync_dir (newdir))
\r
139 > cleanup_path = NULL; /* success */
\r
141 Put the happy day return TRUE here, and don't bother with the above
\r
149 > if (cleanup_path) {
\r
150 > unlink (cleanup_path);
\r
156 Only have the return FALSE path here. You can unconditionally unlink
\r
157 (cleanup_path) too AFAICS.
\r
160 > _______________________________________________
\r
161 > notmuch mailing list
\r
162 > notmuch@notmuchmail.org
\r
163 > http://notmuchmail.org/mailman/listinfo/notmuch
\r