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 175CA431FC4
\r
6 for <notmuch@notmuchmail.org>; Thu, 14 Nov 2013 06:38:00 -0800 (PST)
\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 4mvrzmNt+C1u for <notmuch@notmuchmail.org>;
\r
16 Thu, 14 Nov 2013 06:37:52 -0800 (PST)
\r
17 Received: from mail-we0-f171.google.com (mail-we0-f171.google.com
\r
18 [74.125.82.171]) (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 D331A431FB6
\r
21 for <notmuch@notmuchmail.org>; Thu, 14 Nov 2013 06:37:51 -0800 (PST)
\r
22 Received: by mail-we0-f171.google.com with SMTP id t61so2069322wes.30
\r
23 for <notmuch@notmuchmail.org>; Thu, 14 Nov 2013 06:37:50 -0800 (PST)
\r
24 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
\r
25 d=1e100.net; s=20130820;
\r
26 h=x-gm-message-state:from:to:cc:subject:in-reply-to:references
\r
27 :user-agent:date:message-id:mime-version:content-type;
\r
28 bh=F3IuyrOG7YiYZmu+/JjuBX7uIKx/i8LT5IMR2uTJDpk=;
\r
29 b=LB1OhFHWV6qeAl6sV5BC6CkvA4VbRH9dvf7wnjL8Bv3wiXGZ8qln7hGzx331bo9NLd
\r
30 bT/K0vGN08i/QQulLwshhrp/qZJ7fhe4/lvT3cTr2SASA9pfimaWIS8vvGFjuETpUL1M
\r
31 JkDYYOQfZZeBxL0aGGFQS3PfVg0NFiF6bT0tVhS4YX4sZ5VTXMRQr7J27NagTplGF0Xt
\r
32 zHGo/8W0w1+8CqCDSVuR41jXiZdbUDY6j9/4LjfhIJxXoocOilpFOBUo5SovoFQV0lF3
\r
33 a6yseB3eLQVPxFlXsSWVb4UjZ/LMgDQ31sBsyrAecjvz2szndoqvkKzYcSuy6y1AG0x4
\r
36 ALoCoQl6up+nUhzxy5v3oxhQUZuyhU5DjwhnPd2gcp/wKIDKsKEV+kYZFpU53jffbC7gHtXRaps6
\r
37 X-Received: by 10.180.89.98 with SMTP id bn2mr2824161wib.63.1384438151571;
\r
38 Thu, 14 Nov 2013 06:09:11 -0800 (PST)
\r
39 Received: from localhost ([2001:4b98:dc0:43:216:3eff:fe1b:25f3])
\r
40 by mx.google.com with ESMTPSA id x19sm5550103wia.5.2013.11.14.06.09.10
\r
41 for <multiple recipients>
\r
42 (version=TLSv1.1 cipher=RC4-SHA bits=128/128);
\r
43 Thu, 14 Nov 2013 06:09:10 -0800 (PST)
\r
44 From: Jani Nikula <jani@nikula.org>
\r
45 To: Tomi Ollila <tomi.ollila@iki.fi>, notmuch@notmuchmail.org
\r
46 Subject: Re: [PATCH v2 3/5] compact: preserve backup database until compacted
\r
47 database is in place
\r
48 In-Reply-To: <1384362167-12740-4-git-send-email-tomi.ollila@iki.fi>
\r
49 References: <1384362167-12740-1-git-send-email-tomi.ollila@iki.fi>
\r
50 <1384362167-12740-4-git-send-email-tomi.ollila@iki.fi>
\r
51 User-Agent: Notmuch/0.16+115~gd647c65 (http://notmuchmail.org) Emacs/23.2.1
\r
52 (x86_64-pc-linux-gnu)
\r
53 Date: Thu, 14 Nov 2013 15:08:55 +0100
\r
54 Message-ID: <874n7fnki0.fsf@nikula.org>
\r
56 Content-Type: text/plain; charset=us-ascii
\r
57 Cc: tomi.ollila@iki.fi
\r
58 X-BeenThere: notmuch@notmuchmail.org
\r
59 X-Mailman-Version: 2.1.13
\r
61 List-Id: "Use and development of the notmuch mail system."
\r
62 <notmuch.notmuchmail.org>
\r
63 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
64 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
65 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
66 List-Post: <mailto:notmuch@notmuchmail.org>
\r
67 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
68 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
69 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
70 X-List-Received-Date: Thu, 14 Nov 2013 14:38:00 -0000
\r
72 On Wed, 13 Nov 2013, Tomi Ollila <tomi.ollila@iki.fi> wrote:
\r
73 > It is less error prone and window of failure opportunity is smaller
\r
74 > if the old (backup) database is always renamed (instead of sometimes
\r
75 > rmtree'd) before new (compacted) database is put into its place.
\r
76 > Finally rmtree() old database in case old database backup is not kept.
\r
78 > lib/database.cc | 42 +++++++++++++++++++++++++-----------------
\r
79 > 1 file changed, 25 insertions(+), 17 deletions(-)
\r
81 > diff --git a/lib/database.cc b/lib/database.cc
\r
82 > index 3530cb6..ee09c5e 100644
\r
83 > --- a/lib/database.cc
\r
84 > +++ b/lib/database.cc
\r
85 > @@ -873,6 +873,7 @@ notmuch_database_compact (const char *path,
\r
86 > notmuch_status_t ret = NOTMUCH_STATUS_SUCCESS;
\r
87 > notmuch_database_t *notmuch = NULL;
\r
88 > struct stat statbuf;
\r
89 > + notmuch_bool_t keep_backup;
\r
91 > local = talloc_new (NULL);
\r
93 > @@ -898,17 +899,25 @@ notmuch_database_compact (const char *path,
\r
97 > - if (backup_path != NULL) {
\r
98 > - if (stat (backup_path, &statbuf) != -1) {
\r
99 > - fprintf (stderr, "Backup path already exists: %s\n", backup_path);
\r
100 > - ret = NOTMUCH_STATUS_FILE_ERROR;
\r
103 > - if (errno != ENOENT) {
\r
104 > - fprintf (stderr, "Unknown error while stat()ing backup path: %s\n",
\r
105 > - strerror (errno));
\r
106 > + if (backup_path == NULL) {
\r
107 > + if (! (backup_path = talloc_asprintf (local, "%s.old", xapian_path))) {
\r
108 > + ret = NOTMUCH_STATUS_OUT_OF_MEMORY;
\r
111 > + keep_backup = FALSE;
\r
114 > + keep_backup = TRUE;
\r
116 *cough* I thought you were the style police around here *cough*
\r
119 > + if (stat (backup_path, &statbuf) != -1) {
\r
120 > + fprintf (stderr, "Backup path already exists: %s\n", backup_path);
\r
122 The user will be confused if he specifically didn't add --backup and
\r
123 happens to get this. But maybe it's a corner case. *shrug*.
\r
125 > + ret = NOTMUCH_STATUS_FILE_ERROR;
\r
128 > + if (errno != ENOENT) {
\r
129 > + fprintf (stderr, "Unknown error while stat()ing backup path: %s\n",
\r
130 > + strerror (errno));
\r
138 > @@ -924,14 +933,10 @@ notmuch_database_compact (const char *path,
\r
142 > - if (backup_path) {
\r
143 > - if (rename (xapian_path, backup_path)) {
\r
144 > - fprintf (stderr, "Error moving old database out of the way\n");
\r
145 > - ret = NOTMUCH_STATUS_FILE_ERROR;
\r
149 > - rmtree (xapian_path);
\r
150 > + if (rename (xapian_path, backup_path)) {
\r
151 > + fprintf (stderr, "Error moving old database out of the way\n");
\r
152 > + ret = NOTMUCH_STATUS_FILE_ERROR;
\r
156 > if (rename (compact_xapian_path, xapian_path)) {
\r
157 > @@ -940,6 +945,9 @@ notmuch_database_compact (const char *path,
\r
161 > + if (! keep_backup)
\r
162 > + rmtree (backup_path);
\r
166 > notmuch_database_destroy (notmuch);
\r
170 > _______________________________________________
\r
171 > notmuch mailing list
\r
172 > notmuch@notmuchmail.org
\r
173 > http://notmuchmail.org/mailman/listinfo/notmuch
\r