--- /dev/null
+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 200A8431FCB\r
+ for <notmuch@notmuchmail.org>; Sun, 3 Nov 2013 04:25:43 -0800 (PST)\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 PLP5jADX9ZJm for <notmuch@notmuchmail.org>;\r
+ Sun, 3 Nov 2013 04:25:37 -0800 (PST)\r
+Received: from mail-ee0-f49.google.com (mail-ee0-f49.google.com\r
+ [74.125.83.49]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client\r
+ certificate requested) by olra.theworths.org (Postfix) with ESMTPS id\r
+ 8E2D9429E25 for <notmuch@notmuchmail.org>; Sun, 3 Nov 2013 04:25:13 -0800\r
+ (PST)\r
+Received: by mail-ee0-f49.google.com with SMTP id e52so580835eek.36\r
+ for <notmuch@notmuchmail.org>; Sun, 03 Nov 2013 04:25:12 -0800 (PST)\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=hsWsMcdXmJOySzux5u60RChOOl+XhERARCk5b5+VOzU=;\r
+ b=MAUAhEpwbW3QzY6XQV+1iYZHiOUt5gNx8gOJniDhqVW4OINgokuKcFRVD9Hp/C8jot\r
+ PGFITn73nNUvlxzI0EUBNZm95FHwDmwfDU3rY+vqqmqI9zeUBp18qw7qo+sYd3FbKjrq\r
+ GF5+vU1nEb6Rnois3vJe6lpKcB6rDV8byg15CShLcCF3zmt7IvpBCMVmV4qqMEZ5L6VY\r
+ W9JQ4IRNcOr1vP5+VEbl79NjDfib2+jG9jhpXn2wfxftD2IafdK9Ur2j7RGyIWZ/O+jt\r
+ DdwwxsJU9RiO6ycBdKfAc19/LJFBs/Un2qkf8t5RtB+lCmFOv5pgzwb5szxooq1SReEi\r
+ tfKw==\r
+X-Gm-Message-State:\r
+ ALoCoQnphsxQPLcyzjyYZ0eDQuWtuLLM4OqkKRHGv13zuNELDTUe7BLoFJ+ZT4DYpzMjbSSqNl7o\r
+X-Received: by 10.15.10.6 with SMTP id f6mr1614135eet.57.1383481512392;\r
+ Sun, 03 Nov 2013 04:25:12 -0800 (PST)\r
+Received: from localhost (dsl-hkibrasgw2-58c36f-91.dhcp.inet.fi.\r
+ [88.195.111.91]) by mx.google.com with ESMTPSA id\r
+ u46sm32772104eep.17.2013.11.03.04.25.10 for <multiple recipients>\r
+ (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
+ Sun, 03 Nov 2013 04:25:11 -0800 (PST)\r
+From: Jani Nikula <jani@nikula.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v2 07/11] lib: use the compaction backup path provided by the\r
+ caller\r
+Date: Sun, 3 Nov 2013 14:24:47 +0200\r
+Message-Id:\r
+ <6e8053834c8ab856c2ebab881069f18b2badcf71.1383481295.git.jani@nikula.org>\r
+X-Mailer: git-send-email 1.8.4.rc3\r
+In-Reply-To: <cover.1383481295.git.jani@nikula.org>\r
+References: <cover.1383481295.git.jani@nikula.org>\r
+In-Reply-To: <cover.1383481295.git.jani@nikula.org>\r
+References: <cover.1383481295.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: Sun, 03 Nov 2013 12:25:43 -0000\r
+\r
+The extra path component added by the lib is a magic value that the\r
+caller just has to know. This is demonstrated by the current code,\r
+which indeed has "xapian.old" both sides of the interface. Use the\r
+backup path provided by the lib caller verbatim, without adding\r
+anything to it.\r
+\r
+---\r
+\r
+v2: add xapian.old in cli\r
+---\r
+ lib/database.cc | 14 ++++----------\r
+ notmuch-compact.c | 10 +++++++---\r
+ 2 files changed, 11 insertions(+), 13 deletions(-)\r
+\r
+diff --git a/lib/database.cc b/lib/database.cc\r
+index 5a01703..a021bf1 100644\r
+--- a/lib/database.cc\r
++++ b/lib/database.cc\r
+@@ -868,7 +868,6 @@ notmuch_database_compact (const char* path,\r
+ {\r
+ void *local;\r
+ char *notmuch_path, *xapian_path, *compact_xapian_path;\r
+- char *old_xapian_path = NULL;\r
+ notmuch_status_t ret = NOTMUCH_STATUS_SUCCESS;\r
+ notmuch_database_t *notmuch = NULL;\r
+ struct stat statbuf;\r
+@@ -898,13 +897,8 @@ notmuch_database_compact (const char* path,\r
+ }\r
+ \r
+ if (backup_path != NULL) {\r
+- if (! (old_xapian_path = talloc_asprintf (local, "%s/xapian.old", backup_path))) {\r
+- ret = NOTMUCH_STATUS_OUT_OF_MEMORY;\r
+- goto DONE;\r
+- }\r
+-\r
+- if (stat(old_xapian_path, &statbuf) != -1) {\r
+- fprintf (stderr, "Backup path already exists: %s\n", old_xapian_path);\r
++ if (stat(backup_path, &statbuf) != -1) {\r
++ fprintf (stderr, "Backup path already exists: %s\n", backup_path);\r
+ ret = NOTMUCH_STATUS_FILE_ERROR;\r
+ goto DONE;\r
+ }\r
+@@ -928,8 +922,8 @@ notmuch_database_compact (const char* path,\r
+ goto DONE;\r
+ }\r
+ \r
+- if (old_xapian_path != NULL) {\r
+- if (rename(xapian_path, old_xapian_path)) {\r
++ if (backup_path) {\r
++ if (rename(xapian_path, backup_path)) {\r
+ fprintf (stderr, "Error moving old database out of the way\n");\r
+ ret = NOTMUCH_STATUS_FILE_ERROR;\r
+ goto DONE;\r
+diff --git a/notmuch-compact.c b/notmuch-compact.c\r
+index ee7afcf..55dc731 100644\r
+--- a/notmuch-compact.c\r
++++ b/notmuch-compact.c\r
+@@ -32,9 +32,13 @@ notmuch_compact_command (notmuch_config_t *config,\r
+ unused (char *argv[]))\r
+ {\r
+ const char *path = notmuch_config_get_database_path (config);\r
+- const char *backup_path = path;\r
++ const char *backup_path;\r
+ notmuch_status_t ret;\r
+ \r
++ backup_path = talloc_asprintf (config, "%s/xapian.old", path);\r
++ if (! backup_path)\r
++ return 1;\r
++\r
+ printf ("Compacting database...\n");\r
+ ret = notmuch_database_compact (path, backup_path, status_update_cb, NULL);\r
+ if (ret) {\r
+@@ -42,11 +46,11 @@ notmuch_compact_command (notmuch_config_t *config,\r
+ } else {\r
+ printf ("\n");\r
+ printf ("\n");\r
+- printf ("The old database has been moved to %s/xapian.old", backup_path);\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/xapian.old\n", backup_path);\r
++ printf (" rm -R %s\n", backup_path);\r
+ printf ("\n");\r
+ }\r
+ \r
+-- \r
+1.8.4.rc3\r
+\r