mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-24 20:08:10 +01:00
lib: add interface to delete directory documents
As mentioned in acd66cdec0
we don't have
an interface to delete directory documents, and they're left behind. Add
the interface.
This commit is contained in:
parent
0e03ff3894
commit
727fcd18c6
2 changed files with 35 additions and 0 deletions
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -1761,6 +1761,16 @@ notmuch_directory_get_child_files (notmuch_directory_t *directory);
|
|||
notmuch_filenames_t *
|
||||
notmuch_directory_get_child_directories (notmuch_directory_t *directory);
|
||||
|
||||
/**
|
||||
* Delete directory document from the database, and destroy the
|
||||
* notmuch_directory_t object. Assumes any child directories and files
|
||||
* have been deleted by the caller.
|
||||
*
|
||||
* @since libnotmuch 4.3 (notmuch 0.21)
|
||||
*/
|
||||
notmuch_status_t
|
||||
notmuch_directory_delete (notmuch_directory_t *directory);
|
||||
|
||||
/**
|
||||
* Destroy a notmuch_directory_t object.
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue