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