[PATCH 6/8] CLI: refactor dumping of tags.
[notmuch-archives.git] / c4 / 1bc5a9ec060fb58b36731994607a9312814dfe
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 51A91429E2F\r
6         for <notmuch@notmuchmail.org>; Thu, 17 Feb 2011 23:59:40 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 0\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
12         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 ZDUCmm2eniJZ for <notmuch@notmuchmail.org>;\r
16         Thu, 17 Feb 2011 23:59:39 -0800 (PST)\r
17 Received: from dmz-mailsec-scanner-4.mit.edu (DMZ-MAILSEC-SCANNER-4.MIT.EDU\r
18         [18.9.25.15])\r
19         by olra.theworths.org (Postfix) with ESMTP id E3C45429E3C\r
20         for <notmuch@notmuchmail.org>; Thu, 17 Feb 2011 23:59:31 -0800 (PST)\r
21 X-AuditID: 1209190f-b7c1dae000000a2b-71-4d5e26e3da3e\r
22 Received: from mailhub-auth-3.mit.edu ( [18.9.21.43])\r
23         by dmz-mailsec-scanner-4.mit.edu (Symantec Brightmail Gateway) with\r
24         SMTP id 8C.42.02603.3E62E5D4; Fri, 18 Feb 2011 02:59:31 -0500 (EST)\r
25 Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])\r
26         by mailhub-auth-3.mit.edu (8.13.8/8.9.2) with ESMTP id p1I7xVsd029794; \r
27         Fri, 18 Feb 2011 02:59:31 -0500\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 p1I7xUSa001556\r
33         (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
34         Fri, 18 Feb 2011 02:59:31 -0500 (EST)\r
35 Received: from amthrax by drake.mit.edu with local (Exim 4.72)\r
36         (envelope-from <amthrax@drake.mit.edu>)\r
37         id 1PqLFS-0008LW-Hs; Fri, 18 Feb 2011 02:59:30 -0500\r
38 From: Austin Clements <amdragon@MIT.EDU>\r
39 To: notmuch@notmuchmail.org\r
40 Subject: [PATCH 10/10] new: Wrap adding a message in an atomic section.\r
41 Date: Fri, 18 Feb 2011 02:59:00 -0500\r
42 Message-Id: <1298015940-31986-11-git-send-email-amdragon@mit.edu>\r
43 X-Mailer: git-send-email 1.7.2.3\r
44 In-Reply-To: <1298015940-31986-1-git-send-email-amdragon@mit.edu>\r
45 References: <1298015940-31986-1-git-send-email-amdragon@mit.edu>\r
46 X-Brightmail-Tracker: AAAAAA==\r
47 Cc: amdragon@mit.edu\r
48 X-BeenThere: notmuch@notmuchmail.org\r
49 X-Mailman-Version: 2.1.13\r
50 Precedence: list\r
51 List-Id: "Use and development of the notmuch mail system."\r
52         <notmuch.notmuchmail.org>\r
53 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
54         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
55 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
56 List-Post: <mailto:notmuch@notmuchmail.org>\r
57 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
58 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
59         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
60 X-List-Received-Date: Fri, 18 Feb 2011 07:59:40 -0000\r
61 \r
62 This prevents atomicity violations when adding new messages.  Each\r
63 message add is wrapped in its own atomic section, so interrupting\r
64 notmuch new doesn't loose progress.  Unlike in the remove case, adding\r
65 a message can modify more than one database document, necessitating\r
66 full transactions.\r
67 ---\r
68  notmuch-new.c |   12 ++++++++++++\r
69  1 files changed, 12 insertions(+), 0 deletions(-)\r
70 \r
71 diff --git a/notmuch-new.c b/notmuch-new.c\r
72 index 767722a..880f31a 100644\r
73 --- a/notmuch-new.c\r
74 +++ b/notmuch-new.c\r
75 @@ -424,6 +424,12 @@ add_files_recursive (notmuch_database_t *notmuch,\r
76             fflush (stdout);\r
77         }\r
78  \r
79 +       status = notmuch_database_begin_atomic (notmuch);\r
80 +       if (status) {\r
81 +           ret = status;\r
82 +           goto DONE;\r
83 +       }\r
84 +\r
85         status = notmuch_database_add_message (notmuch, next, &message);\r
86         switch (status) {\r
87         /* success */\r
88 @@ -463,6 +469,12 @@ add_files_recursive (notmuch_database_t *notmuch,\r
89             goto DONE;\r
90         }\r
91  \r
92 +       status = notmuch_database_end_atomic (notmuch);\r
93 +       if (status) {\r
94 +           ret = status;\r
95 +           goto DONE;\r
96 +       }\r
97 +\r
98         if (message) {\r
99             notmuch_message_destroy (message);\r
100             message = NULL;\r
101 -- \r
102 1.7.2.3\r
103 \r