Re: [PATCH 3/3] Add notmuch compact command
authorJani Nikula <jani@nikula.org>
Wed, 17 Oct 2012 19:07:08 +0000 (22:07 +0300)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:49:50 +0000 (09:49 -0800)
99/74ee881786e9bc54e01805d0721242d09acef6 [new file with mode: 0644]

diff --git a/99/74ee881786e9bc54e01805d0721242d09acef6 b/99/74ee881786e9bc54e01805d0721242d09acef6
new file mode 100644 (file)
index 0000000..5ae2747
--- /dev/null
@@ -0,0 +1,198 @@
+Return-Path: <jani@nikula.org>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 334D2431FBD\r
+       for <notmuch@notmuchmail.org>; Wed, 17 Oct 2012 12:07:17 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+       tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id YDtLK6afJV28 for <notmuch@notmuchmail.org>;\r
+       Wed, 17 Oct 2012 12:07:16 -0700 (PDT)\r
+Received: from mail-la0-f53.google.com (mail-la0-f53.google.com\r
+       [209.85.215.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 46EAE431FB6\r
+       for <notmuch@notmuchmail.org>; Wed, 17 Oct 2012 12:07:16 -0700 (PDT)\r
+Received: by mail-la0-f53.google.com with SMTP id l5so5760410lah.26\r
+       for <notmuch@notmuchmail.org>; Wed, 17 Oct 2012 12:07:13 -0700 (PDT)\r
+X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
+       d=google.com; s=20120113;\r
+       h=from:to:subject:in-reply-to:references:user-agent:date:message-id\r
+       :mime-version:content-type:content-transfer-encoding\r
+       :x-gm-message-state;\r
+       bh=MYC1Rq8EAfmt26A6FMxbvJb7NBpI2me670He6a5LN/Y=;\r
+       b=G+TnfDHvPOf0VltsOX5AM6a+cerOzfzp4pFrRAa0xpB1MPe/9+SLEXqz2q3IYo3R0u\r
+       fvzWY6Jqx9+HHCJGSjFueP4w8LIPX2WU5Xb/gqQlKfgHer1YIYaXK6c8FewzPgZd7dD7\r
+       xsIzTR0glvd1KlQSLbY54s+uRwGK0GeWRBu4MwFJWD/RhMD4SKtsG9vYiRDfobxtfN9I\r
+       tpK9TeEIbdOysW/M9FPo/BLSWS8pdCTiceW39ZRsKGR7jrHvxzwY6545jvwgFWWGeKvC\r
+       FsRzy0G9FcU+pKwCyt5gcEu7zhionCVhcGZ9PRiaR0fDMdqi71s1U1fwtBsctNOND4nZ\r
+       k18Q==\r
+Received: by 10.112.101.133 with SMTP id fg5mr7158294lbb.3.1350500833112;\r
+       Wed, 17 Oct 2012 12:07:13 -0700 (PDT)\r
+Received: from localhost (dsl-hkibrasgw4-fe51df00-27.dhcp.inet.fi.\r
+       [80.223.81.27])\r
+       by mx.google.com with ESMTPS id fe5sm4419544lbb.6.2012.10.17.12.07.10\r
+       (version=SSLv3 cipher=OTHER); Wed, 17 Oct 2012 12:07:11 -0700 (PDT)\r
+From: Jani Nikula <jani@nikula.org>\r
+To: Ben Gamari <bgamari.foss@gmail.com>, notmuch@notmuchmail.org\r
+Subject: Re: [PATCH 3/3] Add notmuch compact command\r
+In-Reply-To: <1350487737-32058-4-git-send-email-bgamari.foss@gmail.com>\r
+References: <1350487737-32058-1-git-send-email-bgamari.foss@gmail.com>\r
+       <1350487737-32058-4-git-send-email-bgamari.foss@gmail.com>\r
+User-Agent: Notmuch/0.14+46~g272a1f1 (http://notmuchmail.org) Emacs/23.3.1\r
+       (i686-pc-linux-gnu)\r
+Date: Wed, 17 Oct 2012 22:07:08 +0300\r
+Message-ID: <87y5j42a03.fsf@nikula.org>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=utf-8\r
+Content-Transfer-Encoding: quoted-printable\r
+X-Gm-Message-State:\r
+ ALoCoQk/S1mva9JJzTPMnXMl80YEusvvsRaWjYjVRwunr0pzgTfRe23cAuGX62Z86ODyGK3Udu4B\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Wed, 17 Oct 2012 19:07:17 -0000\r
+\r
+\r
+Nag nag nag: Commit message. ;)\r
+\r
+The custom is to have a man page for each notmuch cli command.\r
+\r
+Small nitpicks below.\r
+\r
+\r
+BR,\r
+Jani.\r
+\r
+\r
+On Wed, 17 Oct 2012, Ben Gamari <bgamari.foss@gmail.com> wrote:\r
+> ---\r
+>  Makefile.local    |    1 +\r
+>  notmuch-client.h  |    3 +++\r
+>  notmuch-compact.c |   43 +++++++++++++++++++++++++++++++++++++++++++\r
+>  notmuch.c         |    3 +++\r
+>  4 files changed, 50 insertions(+)\r
+>  create mode 100644 notmuch-compact.c\r
+>\r
+> diff --git a/Makefile.local b/Makefile.local\r
+> index 7f2d4f1..e050ba6 100644\r
+> --- a/Makefile.local\r
+> +++ b/Makefile.local\r
+> @@ -258,6 +258,7 @@ notmuch_client_srcs =3D          \\r
+>      gmime-filter-headers.c  \\r
+>      hooks.c                 \\r
+>      notmuch.c               \\r
+> +    notmuch-compact.c       \\r
+>      notmuch-config.c        \\r
+>      notmuch-count.c         \\r
+>      notmuch-dump.c          \\r
+> diff --git a/notmuch-client.h b/notmuch-client.h\r
+> index ae9344b..a6c624b 100644\r
+> --- a/notmuch-client.h\r
+> +++ b/notmuch-client.h\r
+> @@ -157,6 +157,9 @@ int\r
+>  notmuch_cat_command (void *ctx, int argc, char *argv[]);\r
+>=20=20\r
+>  int\r
+> +notmuch_compact_command (void *ctx, int argc, char *argv[]);\r
+> +\r
+> +int\r
+>  notmuch_config_command (void *ctx, int argc, char *argv[]);\r
+>=20=20\r
+>  const char *\r
+> diff --git a/notmuch-compact.c b/notmuch-compact.c\r
+> new file mode 100644\r
+> index 0000000..6deb2ec\r
+> --- /dev/null\r
+> +++ b/notmuch-compact.c\r
+> @@ -0,0 +1,43 @@\r
+> +/* notmuch - Not much of an email program, (just index and search)\r
+> + *\r
+> + * Copyright =C2=A9 2009 Carl Worth\r
+\r
+It's your code, this year.\r
+\r
+> + *\r
+> + * This program is free software: you can redistribute it and/or modify\r
+> + * it under the terms of the GNU General Public License as published by\r
+> + * the Free Software Foundation, either version 3 of the License, or\r
+> + * (at your option) any later version.\r
+> + *\r
+> + * This program is distributed in the hope that it will be useful,\r
+> + * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+> + * GNU General Public License for more details.\r
+> + *\r
+> + * You should have received a copy of the GNU General Public License\r
+> + * along with this program.  If not, see http://www.gnu.org/licenses/ .\r
+> + *\r
+> + * Author: Carl Worth <cworth@cworth.org>\r
+\r
+It's your code.\r
+\r
+> + */\r
+> +\r
+> +#include "notmuch-client.h"\r
+> +\r
+> +int\r
+> +notmuch_compact_command (void *ctx, unused (int argc), unused (char *arg=\r
+v[]))\r
+> +{\r
+> +    notmuch_config_t *config;\r
+> +    notmuch_database_t *notmuch;\r
+> +\r
+> +    config =3D notmuch_config_open (ctx, NULL, NULL);\r
+> +    if (config =3D=3D NULL)\r
+> +    return 1;\r
+> +\r
+> +    if (notmuch_database_open (notmuch_config_get_database_path (config),\r
+> +                           NOTMUCH_DATABASE_MODE_READ_WRITE, &notmuch))\r
+> +    return 1;\r
+> +\r
+> +    printf ("Compacting database... ");\r
+> +    notmuch_database_close_compact (notmuch);\r
+> +    printf ("Done.\n");\r
+\r
+Or maybe not. Please add and check the return status of the compact\r
+call.\r
+\r
+> +    notmuch_database_destroy (notmuch);\r
+> +\r
+> +    return 0;\r
+> +}\r
+> diff --git a/notmuch.c b/notmuch.c\r
+> index 477a09c..7b6c5ae 100644\r
+> --- a/notmuch.c\r
+> +++ b/notmuch.c\r
+> @@ -74,6 +74,9 @@ static command_t commands[] =3D {\r
+>      { "restore", notmuch_restore_command,\r
+>        "[--accumulate] [<filename>]",\r
+>        "Restore the tags from the given dump file (see 'dump')." },\r
+> +    { "compact", notmuch_compact_command,\r
+> +      NULL,\r
+> +      "Compacts the database." },\r
+>      { "config", notmuch_config_command,\r
+>        "[get|set] <section>.<item> [value ...]",\r
+>        "Get or set settings in the notmuch configuration file." },\r
+> --=20\r
+> 1.7.10.4\r
+>\r
+> _______________________________________________\r
+> notmuch mailing list\r
+> notmuch@notmuchmail.org\r
+> http://notmuchmail.org/mailman/listinfo/notmuch\r