X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=lib%2Fdirectory.cc;h=5de3319c47d1457f92da38f00717507e67684d9c;hp=8daaec8ee817ed34fd50e4310e05486eba9db833;hb=07dff496304d6dc2e8033a18691b095ed9cd212f;hpb=f5db7ad7d243785c274a99734c681e69d13313d0 diff --git a/lib/directory.cc b/lib/directory.cc index 8daaec8e..5de3319c 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 */ @@ -186,7 +186,7 @@ _notmuch_directory_create (notmuch_database_t *notmuch, directory->mtime = Xapian::sortable_unserialise ( directory->doc.get_value (NOTMUCH_VALUE_TIMESTAMP)); } catch (const Xapian::Error &error) { - fprintf (stderr, + _notmuch_database_log (notmuch, "A Xapian exception occurred creating a directory: %s.\n", error.get_msg().c_str()); notmuch->exception_reported = TRUE; @@ -227,8 +227,11 @@ notmuch_directory_set_mtime (notmuch_directory_t *directory, Xapian::sortable_serialise (mtime)); db->replace_document (directory->document_id, directory->doc); + + directory->mtime = mtime; + } catch (const Xapian::Error &error) { - fprintf (stderr, + _notmuch_database_log (notmuch, "A Xapian exception occurred setting directory mtime: %s.\n", error.get_msg().c_str()); notmuch->exception_reported = TRUE; @@ -281,6 +284,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) {