--- /dev/null
+Return-Path: <bremner@tethera.net>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by arlo.cworth.org (Postfix) with ESMTP id F03FE6DE143A\r
+ for <notmuch@notmuchmail.org>; Sat, 10 Oct 2015 05:30:19 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.105\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.105 tagged_above=-999 required=5 tests=[AWL=0.105]\r
+ autolearn=disabled\r
+Received: from arlo.cworth.org ([127.0.0.1])\r
+ by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id KBw1UOLjUz_S for <notmuch@notmuchmail.org>;\r
+ Sat, 10 Oct 2015 05:30:18 -0700 (PDT)\r
+Received: from gitolite.debian.net (gitolite.debian.net [87.98.215.224])\r
+ by arlo.cworth.org (Postfix) with ESMTPS id 17B976DE140C\r
+ for <notmuch@notmuchmail.org>; Sat, 10 Oct 2015 05:30:18 -0700 (PDT)\r
+Received: from remotemail by gitolite.debian.net with local (Exim 4.80)\r
+ (envelope-from <bremner@tethera.net>)\r
+ id 1ZktGX-0008B3-Ts; Sat, 10 Oct 2015 12:28:45 +0000\r
+Received: (nullmailer pid 8596 invoked by uid 1000); Sat, 10 Oct 2015\r
+ 12:27:30 -0000\r
+From: David Bremner <david@tethera.net>\r
+To: Jani Nikula <jani@nikula.org>, notmuch@notmuchmail.org\r
+Subject: [PATCH 2/3] lib: add interface to delete directory documents\r
+Date: Sat, 10 Oct 2015 09:27:18 -0300\r
+Message-Id: <1444480039-8530-3-git-send-email-david@tethera.net>\r
+X-Mailer: git-send-email 2.5.3\r
+In-Reply-To: <1444480039-8530-1-git-send-email-david@tethera.net>\r
+References:\r
+ <591f5298ac3f2c79f727cac8bad1251830b28a3c.1443213654.git.jani@nikula.org>\r
+ <1444480039-8530-1-git-send-email-david@tethera.net>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.18\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: Sat, 10 Oct 2015 12:30:20 -0000\r
+\r
+From: Jani Nikula <jani@nikula.org>\r
+\r
+As mentioned in acd66cdec075312944e527febd46382e54d99367 we don't have\r
+an interface to delete directory documents, and they're left behind. Add\r
+the interface.\r
+---\r
+ lib/directory.cc | 25 +++++++++++++++++++++++++\r
+ lib/notmuch.h | 10 ++++++++++\r
+ 2 files changed, 35 insertions(+)\r
+\r
+diff --git a/lib/directory.cc b/lib/directory.cc\r
+index b836ea2..78637b3 100644\r
+--- a/lib/directory.cc\r
++++ b/lib/directory.cc\r
+@@ -281,6 +281,31 @@ notmuch_directory_get_child_directories (notmuch_directory_t *directory)\r
+ return child_directories;\r
+ }\r
+ \r
++notmuch_status_t\r
++notmuch_directory_delete (notmuch_directory_t *directory)\r
++{\r
++ notmuch_status_t status;\r
++ Xapian::WritableDatabase *db;\r
++\r
++ status = _notmuch_database_ensure_writable (directory->notmuch);\r
++ if (status)\r
++ return status;\r
++\r
++ try {\r
++ db = static_cast <Xapian::WritableDatabase *> (directory->notmuch->xapian_db);\r
++ db->delete_document (directory->document_id);\r
++ } catch (const Xapian::Error &error) {\r
++ _notmuch_database_log (directory->notmuch,\r
++ "A Xapian exception occurred deleting directory entry: %s.\n",\r
++ error.get_msg().c_str());\r
++ directory->notmuch->exception_reported = TRUE;\r
++ status = NOTMUCH_STATUS_XAPIAN_EXCEPTION;\r
++ }\r
++ notmuch_directory_destroy (directory);\r
++\r
++ return NOTMUCH_STATUS_SUCCESS;\r
++}\r
++\r
+ void\r
+ notmuch_directory_destroy (notmuch_directory_t *directory)\r
+ {\r
+diff --git a/lib/notmuch.h b/lib/notmuch.h\r
+index c5f7dcb..85b56bf 100644\r
+--- a/lib/notmuch.h\r
++++ b/lib/notmuch.h\r
+@@ -1762,6 +1762,16 @@ notmuch_filenames_t *\r
+ notmuch_directory_get_child_directories (notmuch_directory_t *directory);\r
+ \r
+ /**\r
++ * Delete directory document from the database, and destroy the\r
++ * notmuch_directory_t object. Assumes any child directories and files\r
++ * have been deleted by the caller.\r
++ *\r
++ * @since libnotmuch 4.3 (notmuch 0.21)\r
++ */\r
++notmuch_status_t\r
++notmuch_directory_delete (notmuch_directory_t *directory);\r
++\r
++/**\r
+ * Destroy a notmuch_directory_t object.\r
+ */\r
+ void\r
+-- \r
+2.5.3\r
+\r