[PATCH 3/6] lib: use the backup path provided by the user, don't add anything to it

2013-11-02 Thread Jani Nikula
On Nov 2, 2013 2:14 PM, "David Bremner"  wrote:
>
> Jani Nikula  writes:
>
> > Adding another level is just useless cruft.
> > ---
> >  lib/database.cc   |   14 --
> >  notmuch-compact.c |4 ++--
> >  2 files changed, 6 insertions(+), 12 deletions(-)
>
> The first two patches are fine, modulo my comments about documentation.
> I think the backup path needs to be updated in notmuch-compact.c, and
> possible the test updated (after applying
> id:1383350515-24320-1-git-send-email-david at tethera.net)
>
> d

Ah, right, I was juggling the patch order back and forth a bit, and I
missed this (as I drop the path completely in a later patch).

Jani.
-- next part --
An HTML attachment was scrubbed...
URL: 



[PATCH 3/6] lib: use the backup path provided by the user, don't add anything to it

2013-11-02 Thread David Bremner
Jani Nikula  writes:

> Adding another level is just useless cruft.
> ---
>  lib/database.cc   |   14 --
>  notmuch-compact.c |4 ++--
>  2 files changed, 6 insertions(+), 12 deletions(-)

The first two patches are fine, modulo my comments about documentation.
I think the backup path needs to be updated in notmuch-compact.c, and
possible the test updated (after applying
id:1383350515-24320-1-git-send-email-david at tethera.net)

d


Re: [PATCH 3/6] lib: use the backup path provided by the user, don't add anything to it

2013-11-02 Thread David Bremner
Jani Nikula j...@nikula.org writes:

 Adding another level is just useless cruft.
 ---
  lib/database.cc   |   14 --
  notmuch-compact.c |4 ++--
  2 files changed, 6 insertions(+), 12 deletions(-)

The first two patches are fine, modulo my comments about documentation.
I think the backup path needs to be updated in notmuch-compact.c, and
possible the test updated (after applying
id:1383350515-24320-1-git-send-email-da...@tethera.net)

d
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH 3/6] lib: use the backup path provided by the user, don't add anything to it

2013-11-02 Thread Jani Nikula
On Nov 2, 2013 2:14 PM, David Bremner da...@tethera.net wrote:

 Jani Nikula j...@nikula.org writes:

  Adding another level is just useless cruft.
  ---
   lib/database.cc   |   14 --
   notmuch-compact.c |4 ++--
   2 files changed, 6 insertions(+), 12 deletions(-)

 The first two patches are fine, modulo my comments about documentation.
 I think the backup path needs to be updated in notmuch-compact.c, and
 possible the test updated (after applying
 id:1383350515-24320-1-git-send-email-da...@tethera.net)

 d

Ah, right, I was juggling the patch order back and forth a bit, and I
missed this (as I drop the path completely in a later patch).

Jani.
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH 3/6] lib: use the backup path provided by the user, don't add anything to it

2013-11-01 Thread Jani Nikula
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, ) != -1) {
-   fprintf (stderr, "Backup path already exists: %s\n", 
old_xapian_path);
+   if (stat(backup_path, ) != -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



[PATCH 3/6] lib: use the backup path provided by the user, don't add anything to it

2013-11-01 Thread Jani Nikula
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

___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch