the idea is to reduce code duplication and extra object creation with notmuch new --- lib/database.cc | 18 ++++++++++++++---- lib/notmuch.h | 5 +++++ 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/lib/database.cc b/lib/database.cc index 75189685..72592a88 100644 --- a/lib/database.cc +++ b/lib/database.cc @@ -2035,8 +2035,16 @@ notmuch_status_t notmuch_database_remove_message (notmuch_database_t *notmuch, const char *filename) { + return notmuch_database_remove_filename (notmuch, filename, NULL); +} + +notmuch_status_t +notmuch_database_remove_filename (notmuch_database_t *notmuch, + const char *filename, + notmuch_message_t **message_ptr) { + + notmuch_message_t *message = NULL; notmuch_status_t status; - notmuch_message_t *message; status = notmuch_database_find_message_by_filename (notmuch, filename, &message); @@ -2048,12 +2056,14 @@ notmuch_database_remove_message (notmuch_database_t *notmuch, else if (status == NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID) _notmuch_message_sync (message); - notmuch_message_destroy (message); + if (message_ptr) { + *message_ptr = message; + } else { + notmuch_message_destroy (message); + } } - return status; } - notmuch_status_t notmuch_database_find_message_by_filename (notmuch_database_t *notmuch, const char *filename, diff --git a/lib/notmuch.h b/lib/notmuch.h index f9e9cc41..e4c3d2ee 100644 --- a/lib/notmuch.h +++ b/lib/notmuch.h @@ -734,6 +734,11 @@ notmuch_database_find_message_by_filename (notmuch_database_t *notmuch, const char *filename, notmuch_message_t **message); +notmuch_status_t +notmuch_database_remove_filename (notmuch_database_t *notmuch, + const char *filename, + notmuch_message_t **message); + /** * Return a list of all tags found in the database. * -- 2.27.0 _______________________________________________ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-leave@notmuchmail.org