[PATCH 5/6] cli: add compact --backup=FILE option, don't backup by default
authorJani Nikula <jani@nikula.org>
Fri, 1 Nov 2013 14:27:14 +0000 (15:27 +0100)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:57:50 +0000 (09:57 -0800)
f3/a1034537f7f769220867f8fc3cc6d4a643b1f4 [new file with mode: 0644]

diff --git a/f3/a1034537f7f769220867f8fc3cc6d4a643b1f4 b/f3/a1034537f7f769220867f8fc3cc6d4a643b1f4
new file mode 100644 (file)
index 0000000..f8b35e6
--- /dev/null
@@ -0,0 +1,127 @@
+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 3EC9C431FBD\r
+       for <notmuch@notmuchmail.org>; Fri,  1 Nov 2013 07:28:00 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References"\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 0phojprdddnV for <notmuch@notmuchmail.org>;\r
+       Fri,  1 Nov 2013 07:27:55 -0700 (PDT)\r
+Received: from mail-wg0-f53.google.com (mail-wg0-f53.google.com\r
+ [74.125.82.53])       (using TLSv1 with cipher RC4-SHA (128/128 bits))        (No client\r
+ certificate requested)        by olra.theworths.org (Postfix) with ESMTPS id\r
+ 9CD65429E28   for <notmuch@notmuchmail.org>; Fri,  1 Nov 2013 07:27:45 -0700\r
+ (PDT)\r
+Received: by mail-wg0-f53.google.com with SMTP id y10so4095485wgg.8\r
+       for <notmuch@notmuchmail.org>; Fri, 01 Nov 2013 07:27:44 -0700 (PDT)\r
+X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
+       d=1e100.net; s=20130820;\r
+       h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\r
+       :references:in-reply-to:references;\r
+       bh=2RDg5pTDH1RHlqyxw8I66InugiXCX5CCzpaxo7BfZQ8=;\r
+       b=SaHM+qTGWAUVMVBkszEKovYll7KkxQXRwU+TxxLSz7Roq1dyN3FPhZjM8wvv24wGmw\r
+       0m38gSlHwWBJzc9Mmjp96fvqQa4pfFRnAP420OWdts2ju7evv3VT/OD5sfMHVmDw7bMX\r
+       KfA9jrIwM92uOyiuzDFI5b8l0TZF3Bk7L9YwwbSyNUONPkK76+7g05r+KY4TeduPQSJK\r
+       LItMdOuLtWfognC7V8CW6MAKcUXeEHyJogeXs1KYZsSmsI6/sbkVkjHEEWBuYfhKcTiR\r
+       BR/3MqLnq7iegQGZPtoHwFxNPzOVZja4D7cxQi0LFWLnjBCoWVM1uMRUan6oEJO2CraY\r
+       nvcw==\r
+X-Gm-Message-State:\r
+ ALoCoQnFK+0fFO+Aa0I7lcX0Iy6xvQLVqv9L0ica8fGFcjLFGTF3ixoloIYyfhJX0F/QAjKeRM4v\r
+X-Received: by 10.194.21.131 with SMTP id v3mr2609004wje.44.1383316064323;\r
+       Fri, 01 Nov 2013 07:27:44 -0700 (PDT)\r
+Received: from localhost ([2001:4b98:dc0:43:216:3eff:fe1b:25f3])\r
+       by mx.google.com with ESMTPSA id y11sm7982830wie.7.2013.11.01.07.27.43\r
+       for <multiple recipients>\r
+       (version=TLSv1.1 cipher=RC4-SHA bits=128/128);\r
+       Fri, 01 Nov 2013 07:27:43 -0700 (PDT)\r
+From: Jani Nikula <jani@nikula.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 5/6] cli: add compact --backup=FILE option,\r
+       don't backup by default\r
+Date: Fri,  1 Nov 2013 15:27:14 +0100\r
+Message-Id:\r
+ <5a57fca5e59d657ccae4aa564a0d5c66fc276cf5.1383315568.git.jani@nikula.org>\r
+X-Mailer: git-send-email 1.7.2.5\r
+In-Reply-To: <cover.1383315568.git.jani@nikula.org>\r
+References: <cover.1383315568.git.jani@nikula.org>\r
+In-Reply-To: <cover.1383315568.git.jani@nikula.org>\r
+References: <cover.1383315568.git.jani@nikula.org>\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: Fri, 01 Nov 2013 14:28:00 -0000\r
+\r
+It's the user's decision. The recommended way is to do a database dump\r
+anyway. Clean up the relevant printfs too.\r
+---\r
+ notmuch-compact.c |   27 +++++++++++++++------------\r
+ 1 files changed, 15 insertions(+), 12 deletions(-)\r
+\r
+diff --git a/notmuch-compact.c b/notmuch-compact.c\r
+index 2afa725..ecac86a 100644\r
+--- a/notmuch-compact.c\r
++++ b/notmuch-compact.c\r
+@@ -27,13 +27,20 @@ status_update_cb (const char *msg, unused (void *closure))\r
+ }\r
\r
+ int\r
+-notmuch_compact_command (notmuch_config_t *config,\r
+-                       unused (int argc),\r
+-                       unused (char *argv[]))\r
++notmuch_compact_command (notmuch_config_t *config, int argc, char *argv[])\r
+ {\r
+     const char *path = notmuch_config_get_database_path (config);\r
+-    const char *backup_path = path;\r
++    const char *backup_path = NULL;\r
+     notmuch_status_t ret;\r
++    int opt_index;\r
++\r
++    notmuch_opt_desc_t options[] = {\r
++      { NOTMUCH_OPT_STRING, &backup_path, "backup", 0, 0 },\r
++    };\r
++\r
++    opt_index = parse_arguments (argc, argv, options, 1);\r
++    if (opt_index < 0)\r
++      return 1;\r
\r
+     printf ("Compacting database...\n");\r
+     ret = notmuch_database_compact (path, backup_path, status_update_cb, NULL);\r
+@@ -42,14 +49,10 @@ notmuch_compact_command (notmuch_config_t *config,\r
+       return 1;\r
+     }\r
\r
+-    printf ("\n");\r
+-    printf ("\n");\r
+-    printf ("The old database has been moved to %s", backup_path);\r
+-    printf ("\n");\r
+-    printf ("To delete run,\n");\r
+-    printf ("\n");\r
+-    printf ("    rm -R %s\n", backup_path);\r
+-    printf ("\n");\r
++    printf ("Done.\n");\r
++\r
++    if (backup_path)\r
++      printf ("The old database has been moved to %s.\n", backup_path);\r
\r
+     return 0;\r
+ }\r
+-- \r
+1.7.2.5\r
+\r