We never checked to ensure that the rmtree() of the old database
succeeded.

Signed-off-by: Ben Gamari <[email protected]>
---
 lib/database.cc | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/lib/database.cc b/lib/database.cc
index 34753ab..bfc5dac 100644
--- a/lib/database.cc
+++ b/lib/database.cc
@@ -934,7 +934,19 @@ notmuch_database_compact (const char* path,
            goto DONE;
        }
     } else {
-       rmtree(xapian_path);
+       if (rmtree(xapian_path)) {
+           fprintf (stderr, "Error removing old database: %s\n",
+                    strerror(errno));
+           fprintf (stderr, "\n");
+           fprintf (stderr, "Old database: %s\n", xapian_path);
+           fprintf (stderr, "\n");
+           fprintf (stderr, "Please remove the old database and move the 
compacted one in to place manually with\n");
+           fprintf (stderr, "\n");
+           fprintf (stderr, "    mv %s %s\n", compact_xapian_path, 
xapian_path);
+           fprintf (stderr, "\n");
+           ret = NOTMUCH_STATUS_FILE_ERROR;
+           goto DONE;
+       }
     }
 
     if (rename(compact_xapian_path, xapian_path)) {
-- 
1.8.3.2

_______________________________________________
notmuch mailing list
[email protected]
http://notmuchmail.org/mailman/listinfo/notmuch

Reply via email to