Re: [PATCH] add has: query prefix to search for specific properties
[notmuch-archives.git] / 7b / c145ffb7e3a2e177d19313566a5bbe3d9efb3e
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 4D1E2431FDA\r
6         for <notmuch@notmuchmail.org>; Wed,  2 Oct 2013 13:31:10 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.799\r
10 X-Spam-Level: \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 FlPKeZ+jBM+n for <notmuch@notmuchmail.org>;\r
17         Wed,  2 Oct 2013 13:31:05 -0700 (PDT)\r
18 Received: from mail-qc0-f174.google.com (mail-qc0-f174.google.com\r
19         [209.85.216.174]) (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 24E8A431FD6\r
22         for <notmuch@notmuchmail.org>; Wed,  2 Oct 2013 13:31:03 -0700 (PDT)\r
23 Received: by mail-qc0-f174.google.com with SMTP id n9so944021qcw.19\r
24         for <notmuch@notmuchmail.org>; Wed, 02 Oct 2013 13:31:02 -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:in-reply-to:references\r
27         :mime-version:content-type:content-transfer-encoding;\r
28         bh=7jtcxk1tRBwBmX6VIMtPbgHsu86gjby8N+BEE5R14ys=;\r
29         b=yD6Vn4n0MJp1mvW5m1VKvTHqtlMJUPSLc1X9f7R7iSSudgLTNFxhuSEWyq2rCFKsp1\r
30         h9nbTDE9Bu1ipHpS3hqHOULB0zVMcwLbO1ziR2mliGcCkc8D55UnHfilNrBFF/jFZcZT\r
31         JlBFrIDeZKjDw6nEXV9YJsZyIHnqDlZaTnyNgMxQIVCZAwe7aRIq2VczbiUPtR84v+ot\r
32         BsE5gOd7gTDQcswTWjW/vB7mKFnNDhjtB0NlVizENWZbhYezAjv/krdQajwzU/LP875l\r
33         gv4EVdxm91xtMiOE3vNQsUqKivv2kweFdbm9tLLqJnNOrh4oLCv/wXOivuM73BfzI3CR\r
34         6RbQ==\r
35 X-Received: by 10.49.48.168 with SMTP id m8mr5373585qen.25.1380745862606;\r
36         Wed, 02 Oct 2013 13:31:02 -0700 (PDT)\r
37 Received: from ben-laptop.hasb.physics.cns (gamari.physics.umass.edu.\r
38         [128.119.56.223])\r
39         by mx.google.com with ESMTPSA id fx6sm5946200qeb.1.1969.12.31.16.00.00\r
40         (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);\r
41         Wed, 02 Oct 2013 13:31:02 -0700 (PDT)\r
42 From: Ben Gamari <bgamari.foss@gmail.com>\r
43 To: notmuch@notmuchmail.org\r
44 Subject: [PATCH 2/3] notmuch-compact: Initial commit of CLI\r
45 Date: Wed,  2 Oct 2013 16:30:47 -0400\r
46 Message-Id: <1380745848-4972-3-git-send-email-bgamari.foss@gmail.com>\r
47 X-Mailer: git-send-email 1.8.1.2\r
48 In-Reply-To: <1380745848-4972-1-git-send-email-bgamari.foss@gmail.com>\r
49 References: <1380745848-4972-1-git-send-email-bgamari.foss@gmail.com>\r
50 MIME-Version: 1.0\r
51 Content-Type: text/plain; charset=UTF-8\r
52 Content-Transfer-Encoding: 8bit\r
53 X-BeenThere: notmuch@notmuchmail.org\r
54 X-Mailman-Version: 2.1.13\r
55 Precedence: list\r
56 List-Id: "Use and development of the notmuch mail system."\r
57         <notmuch.notmuchmail.org>\r
58 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
59         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
60 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
61 List-Post: <mailto:notmuch@notmuchmail.org>\r
62 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
63 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
64         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
65 X-List-Received-Date: Wed, 02 Oct 2013 20:31:10 -0000\r
66 \r
67 Introduce the user command exposing the new compaction facility.\r
68 \r
69 Signed-off-by: Ben Gamari <bgamari.foss@gmail.com>\r
70 ---\r
71  Makefile.local    |  1 +\r
72  notmuch-client.h  |  3 +++\r
73  notmuch-compact.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++++\r
74  notmuch.c         |  2 ++\r
75  4 files changed, 62 insertions(+)\r
76  create mode 100644 notmuch-compact.c\r
77 \r
78 diff --git a/Makefile.local b/Makefile.local\r
79 index b7cd266..0464a50 100644\r
80 --- a/Makefile.local\r
81 +++ b/Makefile.local\r
82 @@ -257,6 +257,7 @@ notmuch_client_srcs =               \\r
83         gmime-filter-reply.c    \\r
84         hooks.c                 \\r
85         notmuch.c               \\r
86 +       notmuch-compact.c       \\r
87         notmuch-config.c        \\r
88         notmuch-count.c         \\r
89         notmuch-dump.c          \\r
90 diff --git a/notmuch-client.h b/notmuch-client.h\r
91 index afb0ddf..0bfa4da 100644\r
92 --- a/notmuch-client.h\r
93 +++ b/notmuch-client.h\r
94 @@ -204,6 +204,9 @@ notmuch_tag_command (notmuch_config_t *config, int argc, char *argv[]);\r
95  int\r
96  notmuch_config_command (notmuch_config_t *config, int argc, char *argv[]);\r
97  \r
98 +int\r
99 +notmuch_compact_command (notmuch_config_t *config, int argc, char *argv[]);\r
100 +\r
101  const char *\r
102  notmuch_time_relative_date (const void *ctx, time_t then);\r
103  \r
104 diff --git a/notmuch-compact.c b/notmuch-compact.c\r
105 new file mode 100644\r
106 index 0000000..bfda40e\r
107 --- /dev/null\r
108 +++ b/notmuch-compact.c\r
109 @@ -0,0 +1,56 @@\r
110 +/* notmuch - Not much of an email program, (just index and search)\r
111 + *\r
112 + * Copyright © 2013 Ben Gamari\r
113 + *\r
114 + * This program is free software: you can redistribute it and/or modify\r
115 + * it under the terms of the GNU General Public License as published by\r
116 + * the Free Software Foundation, either version 3 of the License, or\r
117 + * (at your option) any later version.\r
118 + *\r
119 + * This program is distributed in the hope that it will be useful,\r
120 + * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
121 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
122 + * GNU General Public License for more details.\r
123 + *\r
124 + * You should have received a copy of the GNU General Public License\r
125 + * along with this program.  If not, see http://www.gnu.org/licenses/ .\r
126 + *\r
127 + * Author: Ben Gamari <bgamari.foss@gmail.com>\r
128 + */\r
129 +\r
130 +#include "notmuch-client.h"\r
131 +\r
132 +void status_update_cb (const char *msg);\r
133 +\r
134 +void\r
135 +status_update_cb (const char *msg)\r
136 +{\r
137 +    printf("%s\n", msg);\r
138 +}\r
139 +\r
140 +int\r
141 +notmuch_compact_command (notmuch_config_t *config,\r
142 +                        unused (int argc),\r
143 +                        unused (char *argv[]))\r
144 +{\r
145 +    const char *path = notmuch_config_get_database_path (config);\r
146 +    const char *backup_path = path;\r
147 +    notmuch_status_t ret;\r
148 +\r
149 +    printf ("Compacting database...\n");\r
150 +    ret = notmuch_database_compact (path, backup_path, status_update_cb);\r
151 +    if (ret) {\r
152 +       fprintf (stderr, "Compaction failed: %s\n", notmuch_status_to_string(ret));\r
153 +    } else {\r
154 +       printf ("\n");\r
155 +       printf ("\n");\r
156 +       printf ("The old database has been moved to %s/xapian.old", backup_path);\r
157 +       printf ("\n");\r
158 +       printf ("To delete run,\n");\r
159 +       printf ("\n");\r
160 +       printf ("    rm -R %s/xapian.old\n", backup_path);\r
161 +       printf ("\n");\r
162 +    }\r
163 +\r
164 +    return 0;\r
165 +}\r
166 diff --git a/notmuch.c b/notmuch.c\r
167 index 7300c21..8d303a1 100644\r
168 --- a/notmuch.c\r
169 +++ b/notmuch.c\r
170 @@ -60,6 +60,8 @@ static command_t commands[] = {\r
171        "Create a plain-text dump of the tags for each message." },\r
172      { "restore", notmuch_restore_command, FALSE,\r
173        "Restore the tags from the given dump file (see 'dump')." },\r
174 +    { "compact", notmuch_compact_command, FALSE,\r
175 +      "Compact the notmuch database." },\r
176      { "config", notmuch_config_command, FALSE,\r
177        "Get or set settings in the notmuch configuration file." },\r
178      { "help", notmuch_help_command, TRUE, /* create but don't save config */\r
179 -- \r
180 1.8.1.2\r
181 \r