From: Ben Gamari Date: Mon, 20 Aug 2012 15:31:44 +0000 (+2000) Subject: [PATCH 3/3] Add notmuch compact command X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=a7c02edd86e35d4f7f6fdaaf6eaa1e3fa3e926cf;p=notmuch-archives.git [PATCH 3/3] Add notmuch compact command --- diff --git a/a2/3481b5bb55a7a55d4fee3beed478dfaf530afa b/a2/3481b5bb55a7a55d4fee3beed478dfaf530afa new file mode 100644 index 000000000..4bd8e7660 --- /dev/null +++ b/a2/3481b5bb55a7a55d4fee3beed478dfaf530afa @@ -0,0 +1,165 @@ +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 9E8BF431FC2 + for ; Mon, 20 Aug 2012 08:31:56 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -0.799 +X-Spam-Level: +X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5 + tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, + FREEMAIL_FROM=0.001, 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 HuMc7I9uRH6a for ; + Mon, 20 Aug 2012 08:31:56 -0700 (PDT) +Received: from mail-vb0-f53.google.com (mail-vb0-f53.google.com + [209.85.212.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id EA1BB431FBD + for ; Mon, 20 Aug 2012 08:31:55 -0700 (PDT) +Received: by vbbfc26 with SMTP id fc26so5986842vbb.26 + for ; Mon, 20 Aug 2012 08:31:55 -0700 (PDT) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; + h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references + :mime-version:content-type:content-transfer-encoding; + bh=W4VCSYkTSHtM0q7CnkAV8Hnjg8fIkYv34UXj92C2Dlw=; + b=0dcjPiOL6PFt5EiyktbPaHf8cysztAiUU3NWQF62wrP/EXF/PpZxIh1Z3zewTzFMln + /qzpZCc6cxkB2jDt7MIi24MCtTgwSOr4o3Sk5WLhS3rVlwO4/MppjoZGWbehfd9IswsS + KiIXti+sPbZnoef4fhbJ7X1ABjaWtJ5Shka6OFO94WHhbVjkEAvJkEhwVVQz7YAYRnZ7 + 6+nBU0YnljQb+TmI2Zd/Y1JPvJUBYqp+NDt5AoEhz6LqVxVD8cZHkAg3hkH/fWWoGxBt + iTZoZfHi76Bw6F5pz11LB4DDX5yrN3CqcXr7NH7aY58EJv040OvGh6PFHgyLI71LcwMo + jy7A== +Received: by 10.52.72.44 with SMTP id a12mr3953564vdv.124.1345476715154; + Mon, 20 Aug 2012 08:31:55 -0700 (PDT) +Received: from localhost.localdomain + (pool-108-8-230-85.spfdma.east.verizon.net. [108.8.230.85]) + by mx.google.com with ESMTPS id g10sm5430786vdk.2.2012.08.20.08.31.54 + (version=SSLv3 cipher=OTHER); Mon, 20 Aug 2012 08:31:54 -0700 (PDT) +From: Ben Gamari +To: notmuch@notmuchmail.org +Subject: =?UTF-8?q?=5BPATCH=203/3=5D=20Add=20notmuch=20compact=20command?= +Date: Mon, 20 Aug 2012 11:31:44 -0400 +Message-Id: <1345476704-17091-4-git-send-email-bgamari.foss@gmail.com> +X-Mailer: git-send-email 1.7.9.5 +In-Reply-To: <1345476704-17091-1-git-send-email-bgamari.foss@gmail.com> +References: <1345476704-17091-1-git-send-email-bgamari.foss@gmail.com> +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit +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: Mon, 20 Aug 2012 15:31:56 -0000 + +--- + 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 de984ab..848605d 100644 +--- a/Makefile.local ++++ b/Makefile.local +@@ -278,6 +278,7 @@ notmuch_client_srcs = \ + 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[]); + + int ++notmuch_compact_command (void *ctx, int argc, char *argv[]); ++ ++int + notmuch_config_command (void *ctx, int argc, char *argv[]); + + 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 © 2009 Carl Worth ++ * ++ * 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 ++ */ ++ ++#include "notmuch-client.h" ++ ++int ++notmuch_compact_command (void *ctx, unused (int argc), unused (char *argv[])) ++{ ++ notmuch_config_t *config; ++ notmuch_database_t *notmuch; ++ ++ config = notmuch_config_open (ctx, NULL, NULL); ++ if (config == 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"); ++ 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[] = { + { "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." }, +-- +1.7.9.5 +