X-Git-Url: https://git.notmuchmail.org/git?a=blobdiff_plain;f=lib%2Fdirectory.cc;h=a19f7779881d8ff0b8da9c2b02a2a2645568facb;hb=6a833a6e83865f6999707cc30768d07e1351c2cb;hp=b836ea2812c88e47b5a8f91007eb24f99b3925ae;hpb=736ac26407914425a9c94e86616225292cf716dd;p=notmuch diff --git a/lib/directory.cc b/lib/directory.cc index b836ea28..a19f7779 100644 --- a/lib/directory.cc +++ b/lib/directory.cc @@ -13,7 +13,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/ . + * along with this program. If not, see https://www.gnu.org/licenses/ . * * Author: Carl Worth */ @@ -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 (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) {