[PATCH 4/4] database: Handle error while deleting uncompacted database
authorBen Gamari <bgamari.foss@gmail.com>
Mon, 28 Oct 2013 22:23:17 +0000 (18:23 +2000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:57:45 +0000 (09:57 -0800)
87/826cda369e020aa51d384098857a80b1a159d4 [new file with mode: 0644]

diff --git a/87/826cda369e020aa51d384098857a80b1a159d4 b/87/826cda369e020aa51d384098857a80b1a159d4
new file mode 100644 (file)
index 0000000..470a482
--- /dev/null
@@ -0,0 +1,100 @@
+Return-Path: <bgamari.foss@gmail.com>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 60ADF431FDA\r
+       for <notmuch@notmuchmail.org>; Mon, 28 Oct 2013 15:23:42 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.799\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5\r
+       tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+       FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id ZWRW3wFx8wKW for <notmuch@notmuchmail.org>;\r
+       Mon, 28 Oct 2013 15:23:37 -0700 (PDT)\r
+Received: from mail-qc0-f173.google.com (mail-qc0-f173.google.com\r
+       [209.85.216.173]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id E15C5431E62\r
+       for <notmuch@notmuchmail.org>; Mon, 28 Oct 2013 15:23:30 -0700 (PDT)\r
+Received: by mail-qc0-f173.google.com with SMTP id l13so4241555qcy.18\r
+       for <notmuch@notmuchmail.org>; Mon, 28 Oct 2013 15:23:30 -0700 (PDT)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
+       h=from:to:cc:subject:date:message-id:in-reply-to:references;\r
+       bh=dG2N3zIEJA0hSNIte4FAXinmqJal/sp0/rD4QdVrVXw=;\r
+       b=ZbTyLbEX17Sk/lmi5II2iDfpGdaQ9T8yrskW4lYWaNCeSBdY2EIqfnGxnKLqBuWzwR\r
+       ETw/Dk+0cmixlfeh2XpOgPL/yyDz7v/yLuGHN2LhMelLy8NGdBsdcuoEzY5eWgvfFUru\r
+       2MiLERMrFETiq4NIJHLWX6hi7BSGqfFFK9eOPhBW5g3TgETzVuAUgnifADKEe6hgzit6\r
+       ppa+4u5lrUa7CZ391YPo7oXBAUUa9nPqdYLzceHGmGRpxKZH0sMdtc43ssMktB+kJrob\r
+       WxzNWhDt7RC2ZJCP1zpAfwJz7q11LpneINKWd/Nxg1B34Gvp3VPdUOWBN161gUWAeB8h\r
+       +vIw==\r
+X-Received: by 10.224.66.5 with SMTP id l5mr28534159qai.31.1382999010266;\r
+       Mon, 28 Oct 2013 15:23:30 -0700 (PDT)\r
+Received: from ben-laptop.hasb.physics.cns (physicsnat56.physics.umass.edu.\r
+       [128.119.50.38])\r
+       by mx.google.com with ESMTPSA id x1sm57796293qai.6.2013.10.28.15.23.29\r
+       for <multiple recipients>\r
+       (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);\r
+       Mon, 28 Oct 2013 15:23:29 -0700 (PDT)\r
+From: Ben Gamari <bgamari.foss@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 4/4] database: Handle error while deleting uncompacted\r
+ database\r
+Date: Mon, 28 Oct 2013 18:23:17 -0400\r
+Message-Id: <1382998997-9938-4-git-send-email-bgamari.foss@gmail.com>\r
+X-Mailer: git-send-email 1.8.3.2\r
+In-Reply-To: <1382998997-9938-1-git-send-email-bgamari.foss@gmail.com>\r
+References: <1382998997-9938-1-git-send-email-bgamari.foss@gmail.com>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Mon, 28 Oct 2013 22:23:42 -0000\r
+\r
+We never checked to ensure that the rmtree() of the old database\r
+succeeded.\r
+\r
+Signed-off-by: Ben Gamari <bgamari.foss@gmail.com>\r
+---\r
+ lib/database.cc | 14 +++++++++++++-\r
+ 1 file changed, 13 insertions(+), 1 deletion(-)\r
+\r
+diff --git a/lib/database.cc b/lib/database.cc\r
+index 34753ab..bfc5dac 100644\r
+--- a/lib/database.cc\r
++++ b/lib/database.cc\r
+@@ -934,7 +934,19 @@ notmuch_database_compact (const char* path,\r
+           goto DONE;\r
+       }\r
+     } else {\r
+-      rmtree(xapian_path);\r
++      if (rmtree(xapian_path)) {\r
++          fprintf (stderr, "Error removing old database: %s\n",\r
++                   strerror(errno));\r
++          fprintf (stderr, "\n");\r
++          fprintf (stderr, "Old database: %s\n", xapian_path);\r
++          fprintf (stderr, "\n");\r
++          fprintf (stderr, "Please remove the old database and move the compacted one in to place manually with\n");\r
++          fprintf (stderr, "\n");\r
++          fprintf (stderr, "    mv %s %s\n", compact_xapian_path, xapian_path);\r
++          fprintf (stderr, "\n");\r
++          ret = NOTMUCH_STATUS_FILE_ERROR;\r
++          goto DONE;\r
++      }\r
+     }\r
\r
+     if (rename(compact_xapian_path, xapian_path)) {\r
+-- \r
+1.8.3.2\r
+\r