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 2342E431FDD
\r
6 for <notmuch@notmuchmail.org>; Sun, 3 Nov 2013 04:25:49 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
8 X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References"
\r
12 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5
\r
13 tests=[RCVD_IN_DNSWL_LOW=-0.7] 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 yOCx0oTxLJva for <notmuch@notmuchmail.org>;
\r
17 Sun, 3 Nov 2013 04:25:43 -0800 (PST)
\r
18 Received: from mail-ee0-f43.google.com (mail-ee0-f43.google.com
\r
19 [74.125.83.43]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client
\r
20 certificate requested) by olra.theworths.org (Postfix) with ESMTPS id
\r
21 B141A431FBF for <notmuch@notmuchmail.org>; Sun, 3 Nov 2013 04:25:18 -0800
\r
23 Received: by mail-ee0-f43.google.com with SMTP id b47so582454eek.16
\r
24 for <notmuch@notmuchmail.org>; Sun, 03 Nov 2013 04:25:17 -0800 (PST)
\r
25 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
\r
26 d=1e100.net; s=20130820;
\r
27 h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to
\r
28 :references:in-reply-to:references;
\r
29 bh=0JB2ZzawPIouY6NvmqrRui1+ge8R9xGhl9qz5SRR5hQ=;
\r
30 b=XhtarUtEQutoYba80XKCCDPhPycNh8GJCOrK6yR7tC0PAAy1LED6eM6gJiwagPf1JF
\r
31 AVfvywCeq5Z1gk4LB+ll3agEfx7M1LtIB3hAen5s5E6QqgAfSPrlXyPlICKdF86N7Dx0
\r
32 0/FPV6JkxeiUxJyVjOqFNnu5CI9Tg7PY7E3KJCM3nvz9oWxq6ZINDUrstY+nw/9FCIfb
\r
33 UH+WYPfhlNM+ocJmiHK3nJX8LEJWHyICWY2yyixZzzhVVknzm7XQ1UAdx/AuyqhPF3NW
\r
34 Gy5QMRfUupQNDtGEZP2npbeVEA9M1AIztKAur9O1B4PdOk4xdlZXCYu7buKRjNR4RuXP
\r
37 ALoCoQnzbGTHD0x06St8avDC4qfTtBRrouMzcntVeGpnHViLC8l3UFl7Y0JbX1cVCyp+6De/vIjR
\r
38 X-Received: by 10.14.246.11 with SMTP id p11mr12725703eer.9.1383481517576;
\r
39 Sun, 03 Nov 2013 04:25:17 -0800 (PST)
\r
40 Received: from localhost (dsl-hkibrasgw2-58c36f-91.dhcp.inet.fi.
\r
41 [88.195.111.91]) by mx.google.com with ESMTPSA id
\r
42 bn13sm32810609eeb.11.2013.11.03.04.25.16 for <multiple recipients>
\r
43 (version=TLSv1.2 cipher=RC4-SHA bits=128/128);
\r
44 Sun, 03 Nov 2013 04:25:17 -0800 (PST)
\r
45 From: Jani Nikula <jani@nikula.org>
\r
46 To: notmuch@notmuchmail.org
\r
47 Subject: [PATCH v2 09/11] cli: add compact --backup=DIRECTORY option,
\r
48 don't backup by default
\r
49 Date: Sun, 3 Nov 2013 14:24:49 +0200
\r
51 <c83913a215774751012213ded201a5adeee8c1dc.1383481295.git.jani@nikula.org>
\r
52 X-Mailer: git-send-email 1.8.4.rc3
\r
53 In-Reply-To: <cover.1383481295.git.jani@nikula.org>
\r
54 References: <cover.1383481295.git.jani@nikula.org>
\r
55 In-Reply-To: <cover.1383481295.git.jani@nikula.org>
\r
56 References: <cover.1383481295.git.jani@nikula.org>
\r
57 X-BeenThere: notmuch@notmuchmail.org
\r
58 X-Mailman-Version: 2.1.13
\r
60 List-Id: "Use and development of the notmuch mail system."
\r
61 <notmuch.notmuchmail.org>
\r
62 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
63 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
64 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
65 List-Post: <mailto:notmuch@notmuchmail.org>
\r
66 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
67 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
68 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
69 X-List-Received-Date: Sun, 03 Nov 2013 12:25:49 -0000
\r
71 It's the user's decision. The recommended way is to do a database dump
\r
72 anyway. Clean up the relevant printfs too.
\r
78 notmuch-compact.c | 27 +++++++++++++--------------
\r
79 test/compact | 4 ++--
\r
80 2 files changed, 15 insertions(+), 16 deletions(-)
\r
82 diff --git a/notmuch-compact.c b/notmuch-compact.c
\r
83 index b9461c2..359acfc 100644
\r
84 --- a/notmuch-compact.c
\r
85 +++ b/notmuch-compact.c
\r
86 @@ -27,16 +27,19 @@ status_update_cb (const char *msg, unused (void *closure))
\r
90 -notmuch_compact_command (notmuch_config_t *config,
\r
91 - unused (int argc),
\r
92 - unused (char *argv[]))
\r
93 +notmuch_compact_command (notmuch_config_t *config, int argc, char *argv[])
\r
95 const char *path = notmuch_config_get_database_path (config);
\r
96 - const char *backup_path;
\r
97 + const char *backup_path = NULL;
\r
98 notmuch_status_t ret;
\r
101 - backup_path = talloc_asprintf (config, "%s/xapian.old", path);
\r
102 - if (! backup_path)
\r
103 + notmuch_opt_desc_t options[] = {
\r
104 + { NOTMUCH_OPT_STRING, &backup_path, "backup", 0, 0 },
\r
107 + opt_index = parse_arguments (argc, argv, options, 1);
\r
108 + if (opt_index < 0)
\r
111 printf ("Compacting database...\n");
\r
112 @@ -46,14 +49,10 @@ notmuch_compact_command (notmuch_config_t *config,
\r
118 - printf ("The old database has been moved to %s", backup_path);
\r
120 - printf ("To delete run,\n");
\r
122 - printf (" rm -R %s\n", backup_path);
\r
125 + printf ("The old database has been moved to %s.\n", backup_path);
\r
127 + printf ("Done.\n");
\r
131 diff --git a/test/compact b/test/compact
\r
132 index afab537..ac174ce 100755
\r
135 @@ -10,7 +10,7 @@ notmuch tag +tag1 \*
\r
136 notmuch tag +tag2 subject:Two
\r
137 notmuch tag -tag1 +tag3 subject:Three
\r
139 -test_expect_success "Running compact" "notmuch compact"
\r
140 +test_expect_success "Running compact" "notmuch compact --backup=${TEST_DIRECTORY}/xapian.old"
\r
142 test_begin_subtest "Compact preserves database"
\r
143 output=$(notmuch search \* | notmuch_search_sanitize)
\r
144 @@ -21,7 +21,7 @@ thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Three (inbox tag3 unread)"
\r
146 test_expect_success 'Restoring Backup' \
\r
147 'rm -Rf ${MAIL_DIR}/.notmuch/xapian &&
\r
148 - mv ${MAIL_DIR}/xapian.old ${MAIL_DIR}/.notmuch/xapian'
\r
149 + mv ${TEST_DIRECTORY}/xapian.old ${MAIL_DIR}/.notmuch/xapian'
\r
151 test_begin_subtest "Checking restored backup"
\r
152 output=$(notmuch search \* | notmuch_search_sanitize)
\r