From 0fab57bb02c6ebb1497b899c241630ab4257b55e Mon Sep 17 00:00:00 2001 From: Jani Nikula Date: Fri, 1 Nov 2013 15:27:12 +0100 Subject: [PATCH] [PATCH 3/6] lib: use the backup path provided by the user, don't add anything to it --- 21/dab7c1563d369d3b014ebdffbf279e4098c284 | 136 ++++++++++++++++++++++ 1 file changed, 136 insertions(+) create mode 100644 21/dab7c1563d369d3b014ebdffbf279e4098c284 diff --git a/21/dab7c1563d369d3b014ebdffbf279e4098c284 b/21/dab7c1563d369d3b014ebdffbf279e4098c284 new file mode 100644 index 000000000..2962abd86 --- /dev/null +++ b/21/dab7c1563d369d3b014ebdffbf279e4098c284 @@ -0,0 +1,136 @@ +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 D2491431FCF + for ; Fri, 1 Nov 2013 07:27:50 -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 G47kYK6BCWOR for ; + Fri, 1 Nov 2013 07:27:46 -0700 (PDT) +Received: from mail-wi0-f169.google.com (mail-wi0-f169.google.com + [209.85.212.169]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 0A7F6431FB6 + for ; Fri, 1 Nov 2013 07:27:39 -0700 (PDT) +Received: by mail-wi0-f169.google.com with SMTP id cb5so1237160wib.0 + for ; Fri, 01 Nov 2013 07:27:39 -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=L6RtrXIIcwBcQfTxl8xlmmmZxLPbjvFVzgpJF1mDeY0=; + b=huA33NhJRaMA8lmR0i1zJ2x0v5iKCDKFcafqjLd9bJFnf46JZaFGv9UeWpicBBzWRD + 2iOMcXeIthN3OMStttmS2ySlY11FDqlEcSs9onXnyuKv9WavSygNJzFFuIguEqAJkP+/ + W8u6QIYxCwojLfwkir/hiHNXMn0ErXdOCbpSYCIwwTPszOcTFAvh61OaX0GnnfiAp5Uy + 6jyXc6waeSsNA35JxLb8Rp7AI2chHMcZeMa/17BRcdyrB2UXZBiFCoynTAP68e77YdSL + 3H2hB5emecvsLtJbB8chUjPpVP/LGOSii1f5AYeX1dOvElVhKdJGpIHyWSCefNl89fNy + pYjA== +X-Gm-Message-State: + ALoCoQm+R/8LoKPJ6SZKu/W80W3wyfDNvcqZv0vM6FeAEtHgGeD5gerfOFT0V6/HASooLT5fWRCd +X-Received: by 10.180.188.164 with SMTP id gb4mr2693858wic.52.1383316058942; + Fri, 01 Nov 2013 07:27:38 -0700 (PDT) +Received: from localhost ([2001:4b98:dc0:43:216:3eff:fe1b:25f3]) + by mx.google.com with ESMTPSA id ey4sm8027832wic.11.2013.11.01.07.27.37 + for + (version=TLSv1.1 cipher=RC4-SHA bits=128/128); + Fri, 01 Nov 2013 07:27:38 -0700 (PDT) +From: Jani Nikula +To: notmuch@notmuchmail.org +Subject: [PATCH 3/6] lib: use the backup path provided by the user, + don't add anything to it +Date: Fri, 1 Nov 2013 15:27:12 +0100 +Message-Id: + <9ee3f2334a117b0a1b88650f44432423cbe95fd7.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:27:51 -0000 + +Adding another level is just useless cruft. +--- + lib/database.cc | 14 ++++---------- + notmuch-compact.c | 4 ++-- + 2 files changed, 6 insertions(+), 12 deletions(-) + +diff --git a/lib/database.cc b/lib/database.cc +index da549b4..9c99ac6 100644 +--- a/lib/database.cc ++++ b/lib/database.cc +@@ -868,7 +868,6 @@ notmuch_database_compact (const char* path, + { + void *local = talloc_new (NULL); + char *notmuch_path, *xapian_path, *compact_xapian_path; +- char *old_xapian_path = NULL; + notmuch_status_t ret = NOTMUCH_STATUS_SUCCESS; + notmuch_database_t *notmuch = NULL; + struct stat statbuf; +@@ -894,13 +893,8 @@ notmuch_database_compact (const char* path, + } + + if (backup_path != NULL) { +- if (! (old_xapian_path = talloc_asprintf (local, "%s/xapian.old", backup_path))) { +- ret = NOTMUCH_STATUS_OUT_OF_MEMORY; +- goto DONE; +- } +- +- if (stat(old_xapian_path, &statbuf) != -1) { +- fprintf (stderr, "Backup path already exists: %s\n", old_xapian_path); ++ if (stat(backup_path, &statbuf) != -1) { ++ fprintf (stderr, "Backup path already exists: %s\n", backup_path); + ret = NOTMUCH_STATUS_FILE_ERROR; + goto DONE; + } +@@ -924,8 +918,8 @@ notmuch_database_compact (const char* path, + goto DONE; + } + +- if (old_xapian_path != NULL) { +- if (rename(xapian_path, old_xapian_path)) { ++ if (backup_path) { ++ if (rename(xapian_path, backup_path)) { + fprintf (stderr, "Error moving old database out of the way\n"); + ret = NOTMUCH_STATUS_FILE_ERROR; + goto DONE; +diff --git a/notmuch-compact.c b/notmuch-compact.c +index ee7afcf..043710f 100644 +--- a/notmuch-compact.c ++++ b/notmuch-compact.c +@@ -42,11 +42,11 @@ notmuch_compact_command (notmuch_config_t *config, + } else { + printf ("\n"); + printf ("\n"); +- printf ("The old database has been moved to %s/xapian.old", backup_path); ++ printf ("The old database has been moved to %s", backup_path); + printf ("\n"); + printf ("To delete run,\n"); + printf ("\n"); +- printf (" rm -R %s/xapian.old\n", backup_path); ++ printf (" rm -R %s\n", backup_path); + printf ("\n"); + } + +-- +1.7.2.5 + -- 2.26.2