Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID incorrectly interpreted as an error #40

Open
elizagamedev opened this issue May 5, 2022 · 1 comment

Comments

@elizagamedev
Copy link
Contributor

This affects Database::index_file and Database::remove_message, as these are only two functions documented to return this status. According to the docs for notmuch_database_index_file:

If 'message' is not NULL, then, on successful return
(NOTMUCH_STATUS_SUCCESS or NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID) '*message'
will be initialized to a message object that can be used for things
such as adding tags to the just-added message. The user should call
notmuch_message_destroy when done with the message. On any failure
'*message' will be set to NULL.

So not only is it not an error, it's also causing a memory leak, since the successful return value is discarded.

I think that it would be fine to fix this issue for the next patch release by treating NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID as successful unconditionally. For the next major release, we should perhaps be returning a tuple struct or something for these two functions (and maybe more that might have been missed) so that the caller can still receive this potentially useful status.

elizagamedev added a commit to elizagamedev/notmuch-rs that referenced this issue May 5, 2022
@vhdirk
Copy link
Owner

vhdirk commented May 6, 2022

Ah, quite true. Thanks for noticing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants