[PATCH 08/10] test: regression for retrieving closed db from message

2020-07-08 Thread David Bremner
This is actually one of the few potentially useful things you can do with a message belonging to a closed database, since in principle you could re-open the database. --- test/T560-lib-error.sh | 16 1 file changed, 16 insertions(+) diff --git a/test/T560-lib-error.sh

[PATCH 10/10] lib: fix return value for n_m_reindex

2020-07-08 Thread David Bremner
Also update the documentation for the behaviour of n_m_get_thread_id that this fix relies on. --- lib/message.cc | 6 -- lib/notmuch.h | 4 ++-- test/T560-lib-error.sh | 1 - 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/message.cc b/lib/message.cc index

[PATCH 01/10] test: add regression test for notmuch_message_has_maildir_flag

2020-07-08 Thread David Bremner
This passes the NULL return inside _ensure_maildir_flags does not break anything. Probably this should be handled more explicitely. --- lib/message.cc | 3 ++- test/T560-lib-error.sh | 16 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/message.cc

[PATCH 07/10] test: regression test for destroying message with closed db

2020-07-08 Thread David Bremner
This should be fine because the message belongs to the database (talloc context wise). --- test/T560-lib-error.sh | 15 +++ 1 file changed, 15 insertions(+) diff --git a/test/T560-lib-error.sh b/test/T560-lib-error.sh index 2bfca179..371b0f9e 100755 --- a/test/T560-lib-error.sh +++

[PATCH 04/10] test: add broken test for n_m_remove_all_tags

2020-07-08 Thread David Bremner
The Xapian exception is actually caught here, but the NULL return is not dealt with properly. --- test/T560-lib-error.sh | 17 + 1 file changed, 17 insertions(+) diff --git a/test/T560-lib-error.sh b/test/T560-lib-error.sh index fb8828fe..acde5786 100755 ---

fourth batch of API cleanup for exception handling

2020-07-08 Thread David Bremner
This continues id:20200705130025.4057292-1-da...@tethera.net and probably needs to be applied on top of it. There are a couple cases here where we use the NULL returns from previous API changes and convert it back into NOTMUCH_STATUS_XAPIAN_EXCEPTION. It isn't the most lovely error path,

[PATCH 06/10] test: regression tests of n_m_freeze and n_m_thaw on closed db

2020-07-08 Thread David Bremner
Neither of these accesses the database, so should be safe. Add the tests to catch any changes in exception throwing. --- test/T560-lib-error.sh | 32 1 file changed, 32 insertions(+) diff --git a/test/T560-lib-error.sh b/test/T560-lib-error.sh index

[PATCH 03/10] test: add regression test for n_m_maildir_flags_to_tags

2020-07-08 Thread David Bremner
This function currently catches at least the obvious Xapian exceptions and we want to keep it that way. --- test/T560-lib-error.sh | 16 1 file changed, 16 insertions(+) diff --git a/test/T560-lib-error.sh b/test/T560-lib-error.sh index 41aad09d..fb8828fe 100755 ---

[PATCH 02/10] lib: add notmuch_message_has_maildir_flag_st

2020-07-08 Thread David Bremner
Initially the new function is mainly tested indirectly via the wrapper. --- lib/message.cc | 41 ++--- lib/notmuch.h | 22 ++ test/T560-lib-error.sh | 17 + 3 files changed, 73 insertions(+), 7 deletions(-)

[PATCH 05/10] lib: handle xapian exception in n_m_remove_all_tags

2020-07-08 Thread David Bremner
At least the exception we already catch should be reported properly. --- lib/message.cc | 10 +++--- lib/notmuch.h | 6 -- test/T560-lib-error.sh | 1 - 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/message.cc b/lib/message.cc index

[PATCH 09/10] test: add known broken test for n_m_reindex on closed db

2020-07-08 Thread David Bremner
This is another case where the code should not call INTERNAL_ERROR. --- test/T560-lib-error.sh | 17 + 1 file changed, 17 insertions(+) diff --git a/test/T560-lib-error.sh b/test/T560-lib-error.sh index ef279e77..e303720c 100755 --- a/test/T560-lib-error.sh +++

Re: [RFC PATCH] lib: document new database_open API

2020-07-08 Thread Floris Bruynooghe
On Sat 04 Jul 2020 at 14:01 -0300, David Bremner wrote: > Floris Bruynooghe writes: > >>> + * >>> + * - in the environment variable NOTMUCH_DATABASE, if non-empty >>> + * >>> + * - by $XDG_DATA_HOME/notmuch/$NOTMUCH_PROFILE where XDG_DATA_HOME >>> + * defaults to "$HOME/.local/share" and

Re: [PATCH 2/4] lib: catch error from closed db in n_m_get_message_id

2020-07-08 Thread Floris Bruynooghe
On Sun 05 Jul 2020 at 08:17 -0300, David Bremner wrote: > David Bremner writes: > >> Floris Bruynooghe writes: >> >>> notmuch_database_get_version currently returns and unsigned int and >>> segfaults on use with a closed db. >> >> Yes, the ones without a proper status value are going to be a

Re: [PATCH 2/4] lib: catch error from closed db in n_m_get_message_id

2020-07-08 Thread Floris Bruynooghe
On Sat 04 Jul 2020 at 14:17 -0300, David Bremner wrote: > Floris Bruynooghe writes: > > >>> - * This function will not return NULL since Notmuch ensures that every >>> - * message has a unique message ID, (Notmuch will generate an ID for a >>> - * message if the original file does not contain