]> git.notmuchmail.org Git - notmuch/commitdiff
compact: improve error messages on failures after compaction
authorTomi Ollila <tomi.ollila@iki.fi>
Thu, 14 Nov 2013 22:03:27 +0000 (00:03 +0200)
committerDavid Bremner <david@tethera.net>
Wed, 20 Nov 2013 00:15:02 +0000 (20:15 -0400)
The error messages written during the steps replacing old
database with new now includes relevant paths and strerror.

lib/database.cc

index d09ad99f505c63b060c6d78ed81bdc79d0b470fb..f395061e3a73f91b3324cc97063e7ba2c149579f 100644 (file)
@@ -942,19 +942,27 @@ notmuch_database_compact (const char *path,
     }
 
     if (rename (xapian_path, backup_path)) {
     }
 
     if (rename (xapian_path, backup_path)) {
-       fprintf (stderr, "Error moving old database out of the way\n");
+       fprintf (stderr, "Error moving %s to %s: %s\n",
+                xapian_path, backup_path, strerror (errno));
        ret = NOTMUCH_STATUS_FILE_ERROR;
        goto DONE;
     }
 
     if (rename (compact_xapian_path, xapian_path)) {
        ret = NOTMUCH_STATUS_FILE_ERROR;
        goto DONE;
     }
 
     if (rename (compact_xapian_path, xapian_path)) {
-       fprintf (stderr, "Error moving compacted database\n");
+       fprintf (stderr, "Error moving %s to %s: %s\n",
+                compact_xapian_path, xapian_path, strerror (errno));
        ret = NOTMUCH_STATUS_FILE_ERROR;
        goto DONE;
     }
 
        ret = NOTMUCH_STATUS_FILE_ERROR;
        goto DONE;
     }
 
-    if (! keep_backup)
-       rmtree (backup_path);
+    if (! keep_backup) {
+       if (rmtree (backup_path)) {
+           fprintf (stderr, "Error removing old database %s: %s\n",
+                    backup_path, strerror (errno));
+           ret = NOTMUCH_STATUS_FILE_ERROR;
+           goto DONE;
+       }
+    }
 
   DONE:
     if (notmuch)
 
   DONE:
     if (notmuch)