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