From: Tomi Ollila Date: Wed, 13 Nov 2013 17:02:47 +0000 (+0200) Subject: [PATCH v2 5/5] compact: provide user more information on after-compaction failures X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=b1a270ea9b75fde4512cc45f95fb47b7a0fc37c5;p=notmuch-archives.git [PATCH v2 5/5] compact: provide user more information on after-compaction failures --- diff --git a/7a/9ecdaa86614b3d4bb3b84ef8da1f05269dcf8b b/7a/9ecdaa86614b3d4bb3b84ef8da1f05269dcf8b new file mode 100644 index 000000000..d291c2238 --- /dev/null +++ b/7a/9ecdaa86614b3d4bb3b84ef8da1f05269dcf8b @@ -0,0 +1,116 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id 2B79D431FC7 + for ; Wed, 13 Nov 2013 09:03:15 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 0 +X-Spam-Level: +X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none] + autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id E0Y5XYJDHiFF for ; + Wed, 13 Nov 2013 09:03:09 -0800 (PST) +Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34]) + by olra.theworths.org (Postfix) with ESMTP id C180F431FDB + for ; Wed, 13 Nov 2013 09:02:57 -0800 (PST) +Received: by guru.guru-group.fi (Postfix, from userid 501) + id 7E9A51000F3; Wed, 13 Nov 2013 19:02:53 +0200 (EET) +From: Tomi Ollila +To: notmuch@notmuchmail.org +Subject: [PATCH v2 5/5] compact: provide user more information on + after-compaction failures +Date: Wed, 13 Nov 2013 19:02:47 +0200 +Message-Id: <1384362167-12740-6-git-send-email-tomi.ollila@iki.fi> +X-Mailer: git-send-email 1.8.0 +In-Reply-To: <1384362167-12740-1-git-send-email-tomi.ollila@iki.fi> +References: <1384362167-12740-1-git-send-email-tomi.ollila@iki.fi> +Cc: tomi.ollila@iki.fi +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Wed, 13 Nov 2013 17:03:15 -0000 + +After database has been compacted, there are steps to put the new +database into place -- and these steps may fail. In case such +failure happens, provide better information how to resolve it. + +Thanks to Ben Gamari for most of the information content. +--- + lib/database.cc | 39 +++++++++++++++++++++++++++++++++++---- + 1 file changed, 35 insertions(+), 4 deletions(-) + +diff --git a/lib/database.cc b/lib/database.cc +index 4b5ac64..a6daac6 100644 +--- a/lib/database.cc ++++ b/lib/database.cc +@@ -939,19 +939,50 @@ notmuch_database_compact (const char *path, + } + + if (rename (xapian_path, backup_path)) { +- fprintf (stderr, "Error moving old database out of the way\n"); ++ fprintf (stderr, "Error moving old database out of the way:\n" ++ "Old database: %s\n" ++ "Backup database: %s\n" ++ "Error: %s\n", xapian_path, backup_path, strerror (errno)); + 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 compacted database into place: %s\n", ++ strerror (errno)); ++ fprintf (stderr, "\n" ++ "Encountered error while moving the compacted database\n" ++ "\n" ++ " %s\n" ++ "\n" ++ "to\n" ++ "\n" ++ " %s\n" ++ "\n" ++ "Please identify the reason for this and move the compacted database\n" ++ "into place manually.\n" ++ "\n" ++ "Alternatively you can revert to the uncompacted database with\n" ++ "\n" ++ " mv '%s' '%s'\n" ++ "\n", compact_xapian_path, xapian_path, ++ backup_path, xapian_path); + ret = NOTMUCH_STATUS_FILE_ERROR; + goto DONE; + } + +- if (! keep_backup) +- rmtree (backup_path); ++ if (! keep_backup) { ++ if (rmtree (backup_path)) { ++ fprintf (stderr, "Error removing backup database: %s\n", ++ strerror (errno)); ++ fprintf (stderr, "\n" ++ "Please remove the backup database with\n" ++ "\n" ++ " rm -rf '%s'\n" "\n", backup_path); ++ ret = NOTMUCH_STATUS_FILE_ERROR; ++ goto DONE; ++ } ++ } + + DONE: + if (notmuch) +-- +1.8.3.1 +