1 Return-Path: <bgamari.foss@gmail.com>
\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 67848431FBD
\r
6 for <notmuch@notmuchmail.org>; Wed, 17 Oct 2012 08:29:41 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5
\r
12 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,
\r
13 FREEMAIL_FROM=0.001, 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 szXn9dfTS7vg for <notmuch@notmuchmail.org>;
\r
17 Wed, 17 Oct 2012 08:29:40 -0700 (PDT)
\r
18 Received: from mail-qc0-f181.google.com (mail-qc0-f181.google.com
\r
19 [209.85.216.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))
\r
20 (No client certificate requested)
\r
21 by olra.theworths.org (Postfix) with ESMTPS id DBF03431FC0
\r
22 for <notmuch@notmuchmail.org>; Wed, 17 Oct 2012 08:29:39 -0700 (PDT)
\r
23 Received: by mail-qc0-f181.google.com with SMTP id x40so6907021qcp.26
\r
24 for <notmuch@notmuchmail.org>; Wed, 17 Oct 2012 08:29:39 -0700 (PDT)
\r
25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
\r
26 h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references
\r
27 :mime-version:content-type:content-transfer-encoding;
\r
28 bh=J0bW1jacLjTDc2u9iaTaEloAeiVJNsJVGdV88eBoyBA=;
\r
29 b=JrayjuRUCX3Hd3t20D2BXmnJp8ZLOpmegFFmDUom3ipUq72cF/V46tN/5G+mKpGOdL
\r
30 u6IbIkrBW5e3DO9fu/GabkSmb6mPwkPPbqH1vtJK8xFeCs8BS3lP6sFWXyPBzQoNhmKk
\r
31 xZlzrBKU98QGfjHZgIzPrgwHDrWAWrnSBF35xF2dJ/WddDnP+OptN0PR6CqJhuaU4RsI
\r
32 NbhezRrt4Lb/hylhHTFa7gzR5JE4G/XsDn1gRoybMAE2LzBygSqbx4hButEoKzGnJm/5
\r
33 BReE8KvyPWf4R04040yDJV3gy+ClemhEYI6OtauvuAWors9IQKqOZJSFmcCo3WYFNATR
\r
35 Received: by 10.49.72.199 with SMTP id f7mr43853326qev.43.1350487779701;
\r
36 Wed, 17 Oct 2012 08:29:39 -0700 (PDT)
\r
37 Received: from ben-laptop.hasb.physics.cns (physicsnat56.physics.umass.edu.
\r
39 by mx.google.com with ESMTPS id eq10sm13366039qab.0.2012.10.17.08.29.39
\r
40 (version=SSLv3 cipher=OTHER); Wed, 17 Oct 2012 08:29:39 -0700 (PDT)
\r
41 From: Ben Gamari <bgamari.foss@gmail.com>
\r
42 To: notmuch@notmuchmail.org
\r
43 Subject: =?UTF-8?q?=5BPATCH=203/3=5D=20Add=20notmuch=20compact=20command?=
\r
44 Date: Wed, 17 Oct 2012 11:28:57 -0400
\r
45 Message-Id: <1350487737-32058-4-git-send-email-bgamari.foss@gmail.com>
\r
46 X-Mailer: git-send-email 1.7.10.4
\r
47 In-Reply-To: <1350487737-32058-1-git-send-email-bgamari.foss@gmail.com>
\r
48 References: <1350487737-32058-1-git-send-email-bgamari.foss@gmail.com>
\r
50 Content-Type: text/plain; charset=UTF-8
\r
51 Content-Transfer-Encoding: 8bit
\r
52 X-BeenThere: notmuch@notmuchmail.org
\r
53 X-Mailman-Version: 2.1.13
\r
55 List-Id: "Use and development of the notmuch mail system."
\r
56 <notmuch.notmuchmail.org>
\r
57 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
58 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
59 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
60 List-Post: <mailto:notmuch@notmuchmail.org>
\r
61 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
62 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
63 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
64 X-List-Received-Date: Wed, 17 Oct 2012 15:29:41 -0000
\r
67 Makefile.local | 1 +
\r
68 notmuch-client.h | 3 +++
\r
69 notmuch-compact.c | 43 +++++++++++++++++++++++++++++++++++++++++++
\r
71 4 files changed, 50 insertions(+)
\r
72 create mode 100644 notmuch-compact.c
\r
74 diff --git a/Makefile.local b/Makefile.local
\r
75 index 7f2d4f1..e050ba6 100644
\r
76 --- a/Makefile.local
\r
77 +++ b/Makefile.local
\r
78 @@ -258,6 +258,7 @@ notmuch_client_srcs = \
\r
79 gmime-filter-headers.c \
\r
82 + notmuch-compact.c \
\r
86 diff --git a/notmuch-client.h b/notmuch-client.h
\r
87 index ae9344b..a6c624b 100644
\r
88 --- a/notmuch-client.h
\r
89 +++ b/notmuch-client.h
\r
90 @@ -157,6 +157,9 @@ int
\r
91 notmuch_cat_command (void *ctx, int argc, char *argv[]);
\r
94 +notmuch_compact_command (void *ctx, int argc, char *argv[]);
\r
97 notmuch_config_command (void *ctx, int argc, char *argv[]);
\r
100 diff --git a/notmuch-compact.c b/notmuch-compact.c
\r
101 new file mode 100644
\r
102 index 0000000..6deb2ec
\r
104 +++ b/notmuch-compact.c
\r
106 +/* notmuch - Not much of an email program, (just index and search)
\r
108 + * Copyright © 2009 Carl Worth
\r
110 + * This program is free software: you can redistribute it and/or modify
\r
111 + * it under the terms of the GNU General Public License as published by
\r
112 + * the Free Software Foundation, either version 3 of the License, or
\r
113 + * (at your option) any later version.
\r
115 + * This program is distributed in the hope that it will be useful,
\r
116 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
117 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
118 + * GNU General Public License for more details.
\r
120 + * You should have received a copy of the GNU General Public License
\r
121 + * along with this program. If not, see http://www.gnu.org/licenses/ .
\r
123 + * Author: Carl Worth <cworth@cworth.org>
\r
126 +#include "notmuch-client.h"
\r
129 +notmuch_compact_command (void *ctx, unused (int argc), unused (char *argv[]))
\r
131 + notmuch_config_t *config;
\r
132 + notmuch_database_t *notmuch;
\r
134 + config = notmuch_config_open (ctx, NULL, NULL);
\r
135 + if (config == NULL)
\r
138 + if (notmuch_database_open (notmuch_config_get_database_path (config),
\r
139 + NOTMUCH_DATABASE_MODE_READ_WRITE, ¬much))
\r
142 + printf ("Compacting database... ");
\r
143 + notmuch_database_close_compact (notmuch);
\r
144 + printf ("Done.\n");
\r
145 + notmuch_database_destroy (notmuch);
\r
149 diff --git a/notmuch.c b/notmuch.c
\r
150 index 477a09c..7b6c5ae 100644
\r
153 @@ -74,6 +74,9 @@ static command_t commands[] = {
\r
154 { "restore", notmuch_restore_command,
\r
155 "[--accumulate] [<filename>]",
\r
156 "Restore the tags from the given dump file (see 'dump')." },
\r
157 + { "compact", notmuch_compact_command,
\r
159 + "Compacts the database." },
\r
160 { "config", notmuch_config_command,
\r
161 "[get|set] <section>.<item> [value ...]",
\r
162 "Get or set settings in the notmuch configuration file." },
\r