diff options
| author | Jani Nikula <jani@nikula.org> | 2015-09-25 23:48:45 +0300 |
|---|---|---|
| committer | David Bremner <david@tethera.net> | 2015-10-10 09:14:25 -0300 |
| commit | 727fcd18c6a3897622582e71a2d71081e3ae40ea (patch) | |
| tree | 0544aba2ee3f34d4b86d350d4a04c3774d73dd70 /lib/directory.cc | |
| parent | 0e03ff389443aa062d30e6949bb3220563c474be (diff) | |
lib: add interface to delete directory documents
As mentioned in acd66cdec075312944e527febd46382e54d99367 we don't have
an interface to delete directory documents, and they're left behind. Add
the interface.
Diffstat (limited to 'lib/directory.cc')
| -rw-r--r-- | lib/directory.cc | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/directory.cc b/lib/directory.cc index b836ea28..78637b3a 100644 --- a/lib/directory.cc +++ b/lib/directory.cc @@ -281,6 +281,31 @@ notmuch_directory_get_child_directories (notmuch_directory_t *directory) return child_directories; } +notmuch_status_t +notmuch_directory_delete (notmuch_directory_t *directory) +{ + notmuch_status_t status; + Xapian::WritableDatabase *db; + + status = _notmuch_database_ensure_writable (directory->notmuch); + if (status) + return status; + + try { + db = static_cast <Xapian::WritableDatabase *> (directory->notmuch->xapian_db); + db->delete_document (directory->document_id); + } catch (const Xapian::Error &error) { + _notmuch_database_log (directory->notmuch, + "A Xapian exception occurred deleting directory entry: %s.\n", + error.get_msg().c_str()); + directory->notmuch->exception_reported = TRUE; + status = NOTMUCH_STATUS_XAPIAN_EXCEPTION; + } + notmuch_directory_destroy (directory); + + return NOTMUCH_STATUS_SUCCESS; +} + void notmuch_directory_destroy (notmuch_directory_t *directory) { |
