From c055a5410a480aba7aa80db7be4ed2e71398ad11 Mon Sep 17 00:00:00 2001 From: Ben Gamari Date: Sat, 24 Aug 2013 22:55:22 +2000 Subject: [PATCH] [PATCH 2/3] notmuch-compact: Initial commit --- a4/0fa1949b3d9d632a9f7365d8c2136fb5ac2961 | 171 ++++++++++++++++++++++ 1 file changed, 171 insertions(+) create mode 100644 a4/0fa1949b3d9d632a9f7365d8c2136fb5ac2961 diff --git a/a4/0fa1949b3d9d632a9f7365d8c2136fb5ac2961 b/a4/0fa1949b3d9d632a9f7365d8c2136fb5ac2961 new file mode 100644 index 000000000..96dbb5198 --- /dev/null +++ b/a4/0fa1949b3d9d632a9f7365d8c2136fb5ac2961 @@ -0,0 +1,171 @@ +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 4DACC429E32 + for ; Fri, 23 Aug 2013 19:55:40 -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 BuHsabDZzCiC for ; + Fri, 23 Aug 2013 19:55:35 -0700 (PDT) +Received: from mail-qe0-f44.google.com (mail-qe0-f44.google.com + [209.85.128.44]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 55A9F431FD9 + for ; Fri, 23 Aug 2013 19:55:31 -0700 (PDT) +Received: by mail-qe0-f44.google.com with SMTP id 5so757329qeb.17 + for ; Fri, 23 Aug 2013 19:55:30 -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:in-reply-to:references + :mime-version:content-type:content-transfer-encoding; + bh=hEsOS6pgxy9QkaJlT5pnQl4Jj+/XHDXiS1y16fxoz9A=; + b=v68OotxsIdVFgEZGbxJwE5lUZ22Dd6AkclVv7XcAY0iXd9V6lS1N4bQqxIQEf+tT6A + rdpHvL2HVFmFxXWCcbbB+aywo4VZB//WQbR5tPGRgGx+wDJQUY8Noob9jxReJWuoR4Qt + 4Vb/fFMhvsuBxG2Wnk+ls05ZbXjq7PAojT2uu7mvCkUa9Vk7qpZDMeDwXqvWe3FKBvCY + 5rTTV+DKJJvk2tX+x32Dq84mCqeOazcRkdvIQTvKabiujxeXCW21b1peTc0PKEEAjXX0 + 0QSZW7mvhDawhddFORhCYwj+VvHKQg9jMZ6Q++W4aclj3YTNknqZAC2l0l64xji4zU9o + 9iBg== +X-Received: by 10.224.160.194 with SMTP id o2mr2613108qax.3.1377312930804; + Fri, 23 Aug 2013 19:55:30 -0700 (PDT) +Received: from localhost.localdomain + (pool-108-8-228-201.spfdma.east.verizon.net. [108.8.228.201]) + by mx.google.com with ESMTPSA id a2sm4350757qek.7.1969.12.31.16.00.00 + (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); + Fri, 23 Aug 2013 19:55:30 -0700 (PDT) +From: Ben Gamari +To: notmuch@notmuchmail.org +Subject: [PATCH 2/3] notmuch-compact: Initial commit +Date: Fri, 23 Aug 2013 22:55:22 -0400 +Message-Id: <1377312923-32274-3-git-send-email-bgamari.foss@gmail.com> +X-Mailer: git-send-email 1.8.1.2 +In-Reply-To: <1377312923-32274-1-git-send-email-bgamari.foss@gmail.com> +References: <1377312923-32274-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: Sat, 24 Aug 2013 02:55:40 -0000 + +Introduce the user command exposing the new compaction facility. + +Signed-off-by: Ben Gamari +--- + Makefile.local | 1 + + notmuch-client.h | 6 ++++++ + notmuch-compact.c | 43 +++++++++++++++++++++++++++++++++++++++++++ + notmuch.c | 2 ++ + 4 files changed, 52 insertions(+) + create mode 100644 notmuch-compact.c + +diff --git a/Makefile.local b/Makefile.local +index b7cd266..0464a50 100644 +--- a/Makefile.local ++++ b/Makefile.local +@@ -257,6 +257,7 @@ notmuch_client_srcs = \ + gmime-filter-reply.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 da332f3..5b8a076 100644 +--- a/notmuch-client.h ++++ b/notmuch-client.h +@@ -203,6 +203,12 @@ notmuch_tag_command (notmuch_config_t *config, int argc, char *argv[]); + int + notmuch_config_command (notmuch_config_t *config, int argc, char *argv[]); + ++int ++notmuch_compact_command (notmuch_config_t *config, int argc, char *argv[]); ++ ++int ++notmuch_config_command (notmuch_config_t *config, int argc, char *argv[]); ++ + const char * + notmuch_time_relative_date (const void *ctx, time_t then); + +diff --git a/notmuch-compact.c b/notmuch-compact.c +new file mode 100644 +index 0000000..72b5c1e +--- /dev/null ++++ b/notmuch-compact.c +@@ -0,0 +1,43 @@ ++/* notmuch - Not much of an email program, (just index and search) ++ * ++ * Copyright © 2013 Ben Gmaari ++ * ++ * 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: Ben Gamari ++ */ ++ ++#include "notmuch-client.h" ++ ++int ++notmuch_compact_command (notmuch_config_t *config, unused (int argc), unused (char *argv[])) ++{ ++ notmuch_database_t *notmuch; ++ notmuch_status_t ret; ++ ++ if (notmuch_database_open (notmuch_config_get_database_path (config), ++ NOTMUCH_DATABASE_MODE_READ_WRITE, ¬much)) ++ return 1; ++ ++ printf ("Compacting database...\n"); ++ ret = notmuch_database_compact_close (notmuch); ++ if (ret) { ++ fprintf (stderr, "Compaction failed: %s\n", notmuch_status_to_string(ret)); ++ } else { ++ printf ("Done.\n"); ++ } ++ notmuch_database_destroy (notmuch); ++ ++ return 0; ++} +diff --git a/notmuch.c b/notmuch.c +index 78d29a8..ab0b1cf 100644 +--- a/notmuch.c ++++ b/notmuch.c +@@ -60,6 +60,8 @@ static command_t commands[] = { + "Create a plain-text dump of the tags for each message." }, + { "restore", notmuch_restore_command, FALSE, + "Restore the tags from the given dump file (see 'dump')." }, ++ { "compact", notmuch_compact_command, FALSE, ++ "Compact the notmuch database." }, + { "config", notmuch_config_command, FALSE, + "Get or set settings in the notmuch configuration file." }, + { "help", notmuch_help_command, TRUE, /* create but don't save config */ +-- +1.8.1.2 + -- 2.26.2