1 Return-Path: <bremner@tethera.net>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by arlo.cworth.org (Postfix) with ESMTP id F03FE6DE143A
\r
6 for <notmuch@notmuchmail.org>; Sat, 10 Oct 2015 05:30:19 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at cworth.org
\r
11 X-Spam-Status: No, score=0.105 tagged_above=-999 required=5 tests=[AWL=0.105]
\r
13 Received: from arlo.cworth.org ([127.0.0.1])
\r
14 by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id KBw1UOLjUz_S for <notmuch@notmuchmail.org>;
\r
16 Sat, 10 Oct 2015 05:30:18 -0700 (PDT)
\r
17 Received: from gitolite.debian.net (gitolite.debian.net [87.98.215.224])
\r
18 by arlo.cworth.org (Postfix) with ESMTPS id 17B976DE140C
\r
19 for <notmuch@notmuchmail.org>; Sat, 10 Oct 2015 05:30:18 -0700 (PDT)
\r
20 Received: from remotemail by gitolite.debian.net with local (Exim 4.80)
\r
21 (envelope-from <bremner@tethera.net>)
\r
22 id 1ZktGX-0008B3-Ts; Sat, 10 Oct 2015 12:28:45 +0000
\r
23 Received: (nullmailer pid 8596 invoked by uid 1000); Sat, 10 Oct 2015
\r
25 From: David Bremner <david@tethera.net>
\r
26 To: Jani Nikula <jani@nikula.org>, notmuch@notmuchmail.org
\r
27 Subject: [PATCH 2/3] lib: add interface to delete directory documents
\r
28 Date: Sat, 10 Oct 2015 09:27:18 -0300
\r
29 Message-Id: <1444480039-8530-3-git-send-email-david@tethera.net>
\r
30 X-Mailer: git-send-email 2.5.3
\r
31 In-Reply-To: <1444480039-8530-1-git-send-email-david@tethera.net>
\r
33 <591f5298ac3f2c79f727cac8bad1251830b28a3c.1443213654.git.jani@nikula.org>
\r
34 <1444480039-8530-1-git-send-email-david@tethera.net>
\r
35 X-BeenThere: notmuch@notmuchmail.org
\r
36 X-Mailman-Version: 2.1.18
\r
38 List-Id: "Use and development of the notmuch mail system."
\r
39 <notmuch.notmuchmail.org>
\r
40 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
41 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
42 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>
\r
43 List-Post: <mailto:notmuch@notmuchmail.org>
\r
44 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
45 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
46 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
47 X-List-Received-Date: Sat, 10 Oct 2015 12:30:20 -0000
\r
49 From: Jani Nikula <jani@nikula.org>
\r
51 As mentioned in acd66cdec075312944e527febd46382e54d99367 we don't have
\r
52 an interface to delete directory documents, and they're left behind. Add
\r
55 lib/directory.cc | 25 +++++++++++++++++++++++++
\r
56 lib/notmuch.h | 10 ++++++++++
\r
57 2 files changed, 35 insertions(+)
\r
59 diff --git a/lib/directory.cc b/lib/directory.cc
\r
60 index b836ea2..78637b3 100644
\r
61 --- a/lib/directory.cc
\r
62 +++ b/lib/directory.cc
\r
63 @@ -281,6 +281,31 @@ notmuch_directory_get_child_directories (notmuch_directory_t *directory)
\r
64 return child_directories;
\r
68 +notmuch_directory_delete (notmuch_directory_t *directory)
\r
70 + notmuch_status_t status;
\r
71 + Xapian::WritableDatabase *db;
\r
73 + status = _notmuch_database_ensure_writable (directory->notmuch);
\r
78 + db = static_cast <Xapian::WritableDatabase *> (directory->notmuch->xapian_db);
\r
79 + db->delete_document (directory->document_id);
\r
80 + } catch (const Xapian::Error &error) {
\r
81 + _notmuch_database_log (directory->notmuch,
\r
82 + "A Xapian exception occurred deleting directory entry: %s.\n",
\r
83 + error.get_msg().c_str());
\r
84 + directory->notmuch->exception_reported = TRUE;
\r
85 + status = NOTMUCH_STATUS_XAPIAN_EXCEPTION;
\r
87 + notmuch_directory_destroy (directory);
\r
89 + return NOTMUCH_STATUS_SUCCESS;
\r
93 notmuch_directory_destroy (notmuch_directory_t *directory)
\r
95 diff --git a/lib/notmuch.h b/lib/notmuch.h
\r
96 index c5f7dcb..85b56bf 100644
\r
99 @@ -1762,6 +1762,16 @@ notmuch_filenames_t *
\r
100 notmuch_directory_get_child_directories (notmuch_directory_t *directory);
\r
103 + * Delete directory document from the database, and destroy the
\r
104 + * notmuch_directory_t object. Assumes any child directories and files
\r
105 + * have been deleted by the caller.
\r
107 + * @since libnotmuch 4.3 (notmuch 0.21)
\r
110 +notmuch_directory_delete (notmuch_directory_t *directory);
\r
113 * Destroy a notmuch_directory_t object.
\r