diff options
author | Jani Nikula <jani@nikula.org> | 2013-11-03 14:24:47 +0200 |
---|---|---|
committer | David Bremner <david@tethera.net> | 2013-11-07 06:51:16 -0400 |
commit | 00d2ac2b41a6dba060837244ee87edce2fd1e465 (patch) | |
tree | bc4c548af1e60690b11f0acd76c4ab2c259ac230 /lib | |
parent | 20abbe89a3014ff27978aea7be0cffbc715935ca (diff) |
lib: use the compaction backup path provided by the caller
The extra path component added by the lib is a magic value that the
caller just has to know. This is demonstrated by the current code,
which indeed has "xapian.old" both sides of the interface. Use the
backup path provided by the lib caller verbatim, without adding
anything to it.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/database.cc | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/lib/database.cc b/lib/database.cc index 5a017034..a021bf17 100644 --- a/lib/database.cc +++ b/lib/database.cc @@ -868,7 +868,6 @@ notmuch_database_compact (const char* path, { void *local; 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; @@ -898,13 +897,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; } @@ -928,8 +922,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; |