From: Tomi Ollila Date: Mon, 11 Nov 2013 17:55:38 +0000 (+0200) Subject: [PATCH 3/3] lib: provide user more information on after-compaction failures X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=0f1cfb9463810ac003665bca900abc1dcb49d334;p=notmuch-archives.git [PATCH 3/3] lib: provide user more information on after-compaction failures --- diff --git a/35/0c917aebf6f077bf94c7c4e7850e181ecb48bc b/35/0c917aebf6f077bf94c7c4e7850e181ecb48bc new file mode 100644 index 000000000..8462b65b9 --- /dev/null +++ b/35/0c917aebf6f077bf94c7c4e7850e181ecb48bc @@ -0,0 +1,115 @@ +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 18972429E4F + for ; Mon, 11 Nov 2013 09:56:00 -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 rOWV1hIRNZL6 for ; + Mon, 11 Nov 2013 09:55:50 -0800 (PST) +Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34]) + by olra.theworths.org (Postfix) with ESMTP id F0743429E31 + for ; Mon, 11 Nov 2013 09:55:49 -0800 (PST) +Received: by guru.guru-group.fi (Postfix, from userid 501) + id A08011000F3; Mon, 11 Nov 2013 19:55:45 +0200 (EET) +From: Tomi Ollila +To: notmuch@notmuchmail.org +Subject: [PATCH 3/3] lib: provide user more information on after-compaction + failures +Date: Mon, 11 Nov 2013 19:55:38 +0200 +Message-Id: <1384192538-15291-4-git-send-email-tomi.ollila@iki.fi> +X-Mailer: git-send-email 1.8.0 +In-Reply-To: <1384192538-15291-1-git-send-email-tomi.ollila@iki.fi> +References: <1384192538-15291-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: Mon, 11 Nov 2013 17:56:00 -0000 + +After database has been compacted, there are steps to put the new +database into place -- and these steps may fail. Provide better +information how to resolve these failure cases. + +Thanks to Ben Gamari for most of the information content. +--- + lib/database.cc | 38 ++++++++++++++++++++++++++++++++++---- + 1 file changed, 34 insertions(+), 4 deletions(-) + +diff --git a/lib/database.cc b/lib/database.cc +index 78693b7..40272dc 100644 +--- a/lib/database.cc ++++ b/lib/database.cc +@@ -937,19 +937,49 @@ 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 +