diff options
| author | David Bremner <david@tethera.net> | 2020-07-04 12:18:05 -0300 |
|---|---|---|
| committer | David Bremner <david@tethera.net> | 2020-07-18 09:52:27 -0300 |
| commit | 2d04ed263121d970cd24a8c26ac924425a7ae3d2 (patch) | |
| tree | 792bf0dc7d1c670d42f58b6d1a9eaa2c54cac502 /lib/message.cc | |
| parent | 13116c5cedf58171d04b5f518b3d6f2fe8aea99d (diff) | |
lib: catch exceptions in n_m_get_flag, provide n_m_get_flag_st
It's not very nice to return FALSE for an error, so provide
notmuch_message_get_flag_st as a migration path.
Bump LIBNOTMUCH_MINOR_VERSION because the API is extended.
Diffstat (limited to 'lib/message.cc')
| -rw-r--r-- | lib/message.cc | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/lib/message.cc b/lib/message.cc index 5ea5aa22..4e1be986 100644 --- a/lib/message.cc +++ b/lib/message.cc @@ -1166,15 +1166,40 @@ notmuch_message_count_files (notmuch_message_t *message) return _notmuch_string_list_length (message->filename_list); } +notmuch_status_t +notmuch_message_get_flag_st (notmuch_message_t *message, + notmuch_message_flag_t flag, + notmuch_bool_t *is_set) +{ + if (! is_set) + return NOTMUCH_STATUS_NULL_POINTER; + + try { + if (flag == NOTMUCH_MESSAGE_FLAG_GHOST && + ! NOTMUCH_TEST_BIT (message->lazy_flags, flag)) + _notmuch_message_ensure_metadata (message, NULL); + } catch (Xapian::Error &error) { + LOG_XAPIAN_EXCEPTION (message, error); + return NOTMUCH_STATUS_XAPIAN_EXCEPTION; + } + + *is_set = NOTMUCH_TEST_BIT (message->flags, flag); + return NOTMUCH_STATUS_SUCCESS; +} + notmuch_bool_t notmuch_message_get_flag (notmuch_message_t *message, notmuch_message_flag_t flag) { - if (flag == NOTMUCH_MESSAGE_FLAG_GHOST && - ! NOTMUCH_TEST_BIT (message->lazy_flags, flag)) - _notmuch_message_ensure_metadata (message, NULL); + notmuch_bool_t is_set; + notmuch_status_t status; + + status = notmuch_message_get_flag_st (message, flag, &is_set); - return NOTMUCH_TEST_BIT (message->flags, flag); + if (status) + return FALSE; + else + return is_set; } void |
