David Bremner [Sun, 19 Jul 2020 12:51:03 +0000 (09:51 -0300)]
lib: fix error return bug with n_d_set_config.
The catch block either needs to return, or the function needs to
return "status". Choose the latter for consistency with
n_d_get_config.
David Bremner [Sun, 19 Jul 2020 12:44:05 +0000 (09:44 -0300)]
test: add known broken test for n_d_set_config
Error status is currently lost.
David Bremner [Sun, 19 Jul 2020 12:39:16 +0000 (09:39 -0300)]
test: add regression test for n_d_get_config
Xapian exceptions seem to handled OK, at least for this case.
David Bremner [Sun, 19 Jul 2020 10:57:39 +0000 (07:57 -0300)]
lib: add regresion test for n_d_get_all_tags
Existing error handling seems adequate, if not ideal.
David Bremner [Sun, 19 Jul 2020 10:43:36 +0000 (07:43 -0300)]
lib: add regression test for n_d_find_message_by_filename
At least this Xapian exception is caught. Make sure it stays that way.
David Bremner [Sun, 19 Jul 2020 10:36:47 +0000 (07:36 -0300)]
lib: rename _n_d_create to _n_d_find_or_create
The error message and name were confusing when called in some "read
only" context.
David Bremner [Sun, 19 Jul 2020 10:13:06 +0000 (07:13 -0300)]
test: add known broken test for notmuch_database_remove_message
The current error message is a bit confusing; fix in next commit.
David Bremner [Sun, 19 Jul 2020 00:11:28 +0000 (21:11 -0300)]
lib: convert relative filenames to absolute in n_d_index_file
The API docs promise to handle relative filenames, but the code did
not do it.
Also check for files outside the mail root, as implied by the API
description.
This fixes the bug reported at
id:87sgdqo0rz.fsf@tethera.net
David Bremner [Fri, 17 Jul 2020 11:02:14 +0000 (08:02 -0300)]
test: add known broken test for indexing relative path
The current code seems to look for the path relative to the current
working directory, rather than the mail store root.
David Bremner [Fri, 17 Jul 2020 10:51:24 +0000 (07:51 -0300)]
test: regression test for n_d_index_file closed db
Current exception handling seems OK, at least for this case.
David Bremner [Fri, 17 Jul 2020 10:38:09 +0000 (07:38 -0300)]
test: add regression test for n_d_get_directory
At least this exception is already handled correctly.
David Bremner [Thu, 16 Jul 2020 23:04:12 +0000 (20:04 -0300)]
test: regression test for n_d_get_revision
This function only accesses data cached by notmuch, so being closed is
not a problem.
David Bremner [Thu, 16 Jul 2020 22:48:19 +0000 (19:48 -0300)]
test: add regression test for n_d_{begin,end}_atomic
Xapian currently succeeds to begin/end a transaction on a closed database,
or at least does not throw an exception. Make the test robust against
this changing.
David Bremner [Thu, 16 Jul 2020 22:34:02 +0000 (19:34 -0300)]
test: regression test for n_d_upgrade
The logic is that if it's acceptable to return SUCCESS for read only
database, it's acceptable for a closed one.
David Bremner [Thu, 16 Jul 2020 22:28:22 +0000 (19:28 -0300)]
lib/n_d_needs_upgrade: handle error return from n_d_get_version
Also clarify documentation of error return from n_d_needs_upgrade.
David Bremner [Thu, 16 Jul 2020 22:22:05 +0000 (19:22 -0300)]
test: add known broken test for n_d_needs_upgrade
It's a bit arbitrary which value to return for errors, but the same
argument as for read only databases applies for errors.
David Bremner [Thu, 16 Jul 2020 02:05:54 +0000 (23:05 -0300)]
test: add regression tests for notmuch database destroy
Either an open or closed database should be ok to destroy
David Bremner [Thu, 16 Jul 2020 01:59:58 +0000 (22:59 -0300)]
test: regression test for closing a closed database
This does not currently throw an error, and it should stay that way.
David Bremner [Tue, 14 Jul 2020 22:31:10 +0000 (19:31 -0300)]
lib/n_d_get_version: catch exceptions and clarify the API
notmuch_database_get_version previously returned 0 on some errors, but
did not document this. Luckily 0 is not a valid database version.
David Bremner [Tue, 14 Jul 2020 11:25:28 +0000 (08:25 -0300)]
lib: move deallocation of memory from n_d_close to n_d_destroy
In order to mimic the "best effort" API of Xapian to provide
information from a closed database when possible, do not
destroy the Xapian database object too early.
Because the pointer to a Xapian database is no longer nulled on close,
introduce a flag to track whether the notmuch database is open or not.
David Bremner [Tue, 14 Jul 2020 00:30:52 +0000 (21:30 -0300)]
test: add known broken test for n_d_get_version on closed db
This should not crash, but it does currently.
David Bremner [Tue, 14 Jul 2020 00:21:03 +0000 (21:21 -0300)]
test: regression tests for n_d_status_string and n_d_get_path
These do not crash on a closed database, and we want to keep it that
way.
Start a new file of tests as T560-lib-error was starting to get unwieldy.
David Bremner [Wed, 22 Jul 2020 11:19:28 +0000 (08:19 -0300)]
lib: fix exception messages for n_m_message_*
The original generic handler had an extra '%s' in the format
string. Update tests that failed to catch this because the template to
print status strings checked 'stat', which was not set.
David Bremner [Wed, 22 Jul 2020 11:35:42 +0000 (08:35 -0300)]
test: sanitize line numbers in exception reports
Prevent test suite churn when reported line numbers change.
Sean Whitton [Wed, 22 Jul 2020 15:11:32 +0000 (08:11 -0700)]
emacs: notmuch-search: avoid wiping out buffer-local variables
David Bremner [Thu, 9 Jul 2020 00:17:09 +0000 (21:17 -0300)]
lib: fix return value for n_m_reindex
Also update the documentation for the behaviour of n_m_get_thread_id
that this fix relies on.
David Bremner [Thu, 9 Jul 2020 00:17:08 +0000 (21:17 -0300)]
test: add known broken test for n_m_reindex on closed db
This is another case where the code should not call INTERNAL_ERROR.
David Bremner [Thu, 9 Jul 2020 00:17:07 +0000 (21:17 -0300)]
test: regression for retrieving closed db from message
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.
David Bremner [Thu, 9 Jul 2020 00:17:06 +0000 (21:17 -0300)]
test: regression test for destroying message with closed db
This should be fine because the message belongs to the
database (talloc context wise).
David Bremner [Thu, 9 Jul 2020 00:17:05 +0000 (21:17 -0300)]
test: regression tests of n_m_freeze and n_m_thaw on closed db
Neither of these accesses the database, so should be safe. Add the
tests to catch any changes in exception throwing.
David Bremner [Thu, 9 Jul 2020 00:17:04 +0000 (21:17 -0300)]
lib: handle xapian exception in n_m_remove_all_tags
At least the exception we already catch should be reported properly.
David Bremner [Thu, 9 Jul 2020 00:17:03 +0000 (21:17 -0300)]
test: add broken test for n_m_remove_all_tags
The Xapian exception is actually caught here, but the NULL return is
not dealt with properly.
David Bremner [Thu, 9 Jul 2020 00:17:02 +0000 (21:17 -0300)]
test: add regression test for n_m_maildir_flags_to_tags
This function currently catches at least the obvious Xapian exceptions
and we want to keep it that way.
David Bremner [Mon, 13 Jul 2020 23:51:07 +0000 (20:51 -0300)]
cli/new: replace newly deprecated n_m_has_maildir_flag
Boolean return values have no out-of-band-values to signal errors. The
change here is that a (somewhat unlikely) fatal error after indexing
will now be caught.
David Bremner [Thu, 9 Jul 2020 00:17:01 +0000 (21:17 -0300)]
lib: add notmuch_message_has_maildir_flag_st
Initially the new function is mainly tested indirectly via the
wrapper.
David Bremner [Thu, 9 Jul 2020 00:17:00 +0000 (21:17 -0300)]
test: add regression test for notmuch_message_has_maildir_flag
This passes the NULL return inside _ensure_maildir_flags does not
break anything. Probably this should be handled more explicitely.
David Bremner [Wed, 15 Jul 2020 12:36:27 +0000 (09:36 -0300)]
configure: replace multiple redirects with redirected block
This belatedly implements Tomi's suggestion from
id:m25zaukv6u.fsf@guru.guru-group.fi
David Bremner [Sat, 11 Jul 2020 18:30:08 +0000 (15:30 -0300)]
bindings/ruby: replacy use of deprecated notmuch_message_get_flag
Depending on the flag, this actually can return an errror, so raise a
ruby exception if so.
David Bremner [Sat, 11 Jul 2020 18:30:07 +0000 (15:30 -0300)]
lib/thread: replace use of deprecated notmuch_message_get_flag
This adds one more reason why _notmuch_thread_create might return
NULL, but those were not previously enumerated, so no promises are
broken.
David Bremner [Sat, 11 Jul 2020 18:30:06 +0000 (15:30 -0300)]
lib/add-message: drop use of deprecated notmuch_message_get_flag.
As a side effect, we revert the switch from notmuch_bool_t to bool
here. This is because those two types are not actually compatible when
passing by reference.
David Bremner [Sat, 11 Jul 2020 18:30:05 +0000 (15:30 -0300)]
cli/show: replace deprecated notmuch_message_get_flag
This can be seen as moving an abort out of the library, into the CLI
where we can both print to stderr and shut the process down without
ill effect.
David Bremner [Sat, 11 Jul 2020 18:30:04 +0000 (15:30 -0300)]
cli/search: replace deprecated notmuch_message_get_flag
Our handling of errors is all or nothing here, but it's an improvement
on the status quo, and it avoids rippling internal API changes.
David Bremner [Sat, 4 Jul 2020 15:18:05 +0000 (12:18 -0300)]
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.
David Bremner [Thu, 16 Jul 2020 18:59:45 +0000 (15:59 -0300)]
configure: make sure WITH_PYTHON_DOCS is initialized
Thanks to pazz for reporting the problem.
David Bremner [Sat, 11 Jul 2020 13:20:27 +0000 (10:20 -0300)]
doc: add new python bindings to main documentation tree.
A separate conf.py and doc directory (or will be needed if someone wants
to build the bindings docs separately from notmuch.
David Bremner [Sat, 11 Jul 2020 13:20:26 +0000 (10:20 -0300)]
doc: replace use of environment variables with a generated config
It is getting unwieldy to pass configuration options on the
sphinx-build command line, and I anticipate further use of
conditionals.
As far as I could tell, execing a string is the idiomatic way to
emulate include in Python.
David Bremner [Sun, 5 Jul 2020 13:00:26 +0000 (10:00 -0300)]
lib: use COERCE_STATUS in n_m_{add,remove}_tag
Currently I don't know of a good way of testing this, but at least in
principle a Xapian exception in _notmuch_message_{add,remove}_term
would cause an abort in the library.
David Bremner [Sun, 5 Jul 2020 13:00:25 +0000 (10:00 -0300)]
lib: catch Xapian exceptions in n_m_remove_tag
The churn here is again mainly re-indentation.
David Bremner [Sun, 5 Jul 2020 13:00:24 +0000 (10:00 -0300)]
test: add broken test for n_m_remove_tag
Exception will be caught in next commit.
David Bremner [Sun, 5 Jul 2020 13:00:23 +0000 (10:00 -0300)]
lib: catch Xapian exceptions in n_m_add_tag
This is mostly just (horizontal) code movement due to wrapping
everything in a try / catch.
David Bremner [Sun, 5 Jul 2020 13:00:22 +0000 (10:00 -0300)]
test: add known broken test for n_m_add_tag with closed db
Exception will be caught in next commit.
David Bremner [Sun, 5 Jul 2020 13:00:21 +0000 (10:00 -0300)]
lib: catch Xapian exceptions in n_m_count_files
This will require some care for the caller to check the sign, and not
just add error returns into a running total.
David Bremner [Sun, 5 Jul 2020 13:00:20 +0000 (10:00 -0300)]
test: add known broken test for n_m_count_files
This will be fixed in the next commit.
David Bremner [Sun, 5 Jul 2020 13:00:19 +0000 (10:00 -0300)]
lib: catch Xapian exceptions in n_m_get_tags
This allows the function to return an error value rather than
crashing.
David Bremner [Sun, 5 Jul 2020 13:00:18 +0000 (10:00 -0300)]
test: add known broken test for n_m_get_tags
This will be fixed in the next commit.
David Bremner [Sun, 5 Jul 2020 13:00:17 +0000 (10:00 -0300)]
lib: use LOG_XAPIAN_EXCEPTION in n_m_get_date
This should not change functionality, but does slightly reduce code
duplication. Perhaps more importantly it allows consistent changes to
all of the similar exception handling in message.cc.
David Bremner [Sun, 5 Jul 2020 13:00:16 +0000 (10:00 -0300)]
lib: add regression test for n_m_get_date; clarify API
This function catches Xapian exceptions. The test is intended to make
sure it stays that way.
David Bremner [Sat, 4 Jul 2020 14:22:25 +0000 (11:22 -0300)]
test: add known broken for n_m_get_flag on closed db
Exception caught in next commit. Note that FLAG_GHOST is the only one
that triggers the I/O code path.
David Bremner [Sat, 4 Jul 2020 14:09:09 +0000 (11:09 -0300)]
lib: catch exceptions in n_m_get_filenames
This is essentially copied from the change to notmuch_message_get_filename
David Bremner [Sat, 4 Jul 2020 14:06:37 +0000 (11:06 -0300)]
test: add known broken test for n_m_get_filenames
This will be fixed in the next commit
David Bremner [Sat, 4 Jul 2020 12:20:31 +0000 (09:20 -0300)]
lib/n_m_g_filename: catch Xapian exceptions, document NULL return
This is the same machinery as applied for
notmuch_message_get_{thread,message}_id
David Bremner [Sat, 4 Jul 2020 12:16:30 +0000 (09:16 -0300)]
lib: add known broken test for notmuch_message_get_filename
This will be fixed in the next commit
David Bremner [Sat, 4 Jul 2020 12:09:09 +0000 (09:09 -0300)]
lib/n_m_get_replies: doc return, initial regression test
We need to to set a query and retrieve the threads to meaningfully
test this function.
David Bremner [Sat, 4 Jul 2020 11:35:08 +0000 (08:35 -0300)]
test: add regression test for n_m_get_header
This function already catches Xapian exceptions, and we want to make
sure it stays that way.
David Bremner [Sat, 4 Jul 2020 11:33:41 +0000 (08:33 -0300)]
lib/message: use LOG_XAPIAN_EXCEPTION in n_m_get_header
This is just for consistency, and a small reduction in the amount of
boilerplate.
David Bremner [Sat, 4 Jul 2020 12:29:41 +0000 (09:29 -0300)]
test: drop use of assert in closed db tests
Instead of printing the same static string for each test, can replace
the assert with something simpler (or at least easier to integrate
into the test suite).
David Bremner [Sat, 4 Jul 2020 11:12:21 +0000 (08:12 -0300)]
test: remove unused backup_database calls
Since these backups are never restored, they should be safe to remove.
David Bremner [Sat, 11 Jul 2020 22:52:21 +0000 (19:52 -0300)]
debian: drop ValueRangeProcessor symbols
These are not used since
b90d852
David Bremner [Tue, 7 Jul 2020 10:56:47 +0000 (07:56 -0300)]
test: drop upgrade from v1 tests
These are less crucial since we stopped generating new database
versions and relied primarily on features. They also rely on a
pre-generated v1 database which happens to be chert format. This
backend is not supported by Xapian 1.5.
Also drop the tool gen-testdb.sh, which is currently broken, due to
changes in the testing infrastructure.
David Bremner [Tue, 7 Jul 2020 10:56:46 +0000 (07:56 -0300)]
lib: migrate from Xapian ValueRangeProcessor to RangeProcessor
This will be mandatory as of Xapian 1.5. The API is also more
consistent with the FieldProcessor API, which helps code re-use a bit.
Note that this switches to using the built-in Xapian support for
prefixes on ranges (i.e. deleted code at beginning of
ParseTimeRangeProcessor::operator(), added prefix to constructor).
Another side effect of the migration is that we are generating smaller
queries, using one OP_VALUE_RANGE instead of an AND of two OP_VALUE_*
queries.
David Bremner [Tue, 7 Jul 2020 10:56:45 +0000 (07:56 -0300)]
lib: migrate to post Xapian 1.3.4 compact support
The old API was deprecated in Xapian 1.3.4 and (will be) removed in 1.5.0
Jonas Witschel [Sat, 11 Jul 2020 16:04:35 +0000 (18:04 +0200)]
doc: make gzipped man pages reproducible
gzip includes the name of the uncompressed file and its modification
timestamp into the compressed archive. The latter makes it hard to
reproduce the generated files bit for bit at a later time, so omit this
information from the archive using the "--no-name" option. This is a
reproducibility best practice, see
https://wiki.debian.org/ReproducibleBuilds/TimestampsInGzipHeaders
David Bremner [Sat, 11 Jul 2020 02:24:41 +0000 (23:24 -0300)]
Merge branch 'release'
David Bremner [Sat, 11 Jul 2020 01:25:04 +0000 (22:25 -0300)]
NEWS: update date for release
David Bremner [Sat, 11 Jul 2020 01:24:41 +0000 (22:24 -0300)]
debian: changelog for 0.30
David Bremner [Sat, 11 Jul 2020 01:21:19 +0000 (22:21 -0300)]
version: set to 0.30
David Bremner [Tue, 30 Jun 2020 01:14:11 +0000 (22:14 -0300)]
lib/message: catch exception in n_m_get_thread_id
This allows us to return an error value from the library.
David Bremner [Tue, 30 Jun 2020 01:14:10 +0000 (22:14 -0300)]
test: add known broken test for n_m_get_thread_id on closed db
This will be fixed in the next commit.
David Bremner [Tue, 30 Jun 2020 01:14:09 +0000 (22:14 -0300)]
lib: catch error from closed db in n_m_get_message_id
By catching it at the library top level, we can return an error value.
David Bremner [Tue, 30 Jun 2020 01:14:08 +0000 (22:14 -0300)]
test: add known broken test for error handling on closed database
Based on id:87d05je1j6.fsf@powell.devork.be
David Bremner [Tue, 16 Jun 2020 14:17:55 +0000 (11:17 -0300)]
build: produce signatures for release candidate tarballs.
Today Defalos on #notmuch asked for a signed tarball for
0.30~rc2. This is a minimal change to support this in the future. The
question of automagically uploading will need more thought; currently
I like the fact that tags from pre-releases are only pushed manually.
David Bremner [Fri, 3 Jul 2020 10:23:32 +0000 (07:23 -0300)]
test: fix python 3.8.4 related regression in T210-raw
It seems (at least in 3.8.4~rc1-1 on Debian) that set_content requires
at least one line.
David Bremner [Fri, 3 Jul 2020 09:50:16 +0000 (06:50 -0300)]
debian: changelog fo 0.30~rc3-1
David Bremner [Fri, 3 Jul 2020 09:45:17 +0000 (06:45 -0300)]
version: bump to 0.30~rc3
David Bremner [Tue, 30 Jun 2020 00:22:47 +0000 (21:22 -0300)]
bindings/python-cffi: copy version file into bindings dir
Attempt to avoid breaking "pip install ."
As far as I can tell, we need to have a copy (not just a relative
symlink) of the version file.
David Bremner [Fri, 26 Jun 2020 11:11:00 +0000 (08:11 -0300)]
doc: update install suggestions for fedora derivatives
Fedora still has an old gmime-devel which is 2.6.x. This is no longer
supported by notmuch. Also apparently dnf is a better choice than yum.
Daniel Kahn Gillmor [Thu, 2 Jul 2020 18:00:49 +0000 (14:00 -0400)]
tests: mark sig verification known-broken with session keys on buggy gpgme
We make use of the just-introduced configure test.
Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
Daniel Kahn Gillmor [Thu, 2 Jul 2020 18:00:48 +0000 (14:00 -0400)]
configure: can gpgme can verify signatures when decrypting with a session key?
If https://dev.gnupg.org/T3464 is unresolved in the version of gpgme
we are testing against, then we should know about it, because it
affects the behavior of notmuch.
Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
David Bremner [Wed, 24 Jun 2020 14:32:34 +0000 (11:32 -0300)]
test: mark two tests broken on machines with 32 bit time_t
I haven't traced the code path as exhaustively for the SMIME test, but
the expiry date in question is larger then representable in a signed
32 bit integer.
David Bremner [Wed, 24 Jun 2020 14:32:33 +0000 (11:32 -0300)]
configure: detect 64 bit time_t
Certain tests involving timestamps > 32 bits cannot pass with the
current libnotmuch API. We will avoid this issue for now by disabling
those tests on "old" architectures with 32 bit time_t.
Tomi Ollila [Wed, 24 Jun 2020 20:11:20 +0000 (23:11 +0300)]
Makefile.global: drop -std=gnu99. C11 (or later) compiler required
Since October 2018 building notmuch has actually required compiler
that knows C11.
Also this -std=gnu99 was not used in code compiled by configure,
so in theory this could have caused problems...
...but no related reports have been sent, perhaps ever.
Both gcc and clang has been shipping compilers supporting C11
(or later) by default for more than four years now.
Therefore, just dropping -std=gnu99 (and not checking C11
compatibility for now, for simplicity) is easiest to do,
and removes inconsistency between configure and build time
compilations.
Floris Bruynooghe [Fri, 19 Jun 2020 09:46:28 +0000 (11:46 +0200)]
python-cffi: read version from notmuch version file
This keeps it in sync with the main notmuch version which is less
confusing to users.
David Bremner [Tue, 16 Jun 2020 11:32:51 +0000 (08:32 -0300)]
debian: changelog stanza for 0.30~rc2-1
David Bremner [Tue, 16 Jun 2020 11:29:39 +0000 (08:29 -0300)]
version: update to 0.30~rc2
David Bremner [Tue, 16 Jun 2020 11:28:08 +0000 (08:28 -0300)]
debian/copyright: update to match AUTHORS
David Bremner [Tue, 16 Jun 2020 11:26:55 +0000 (08:26 -0300)]
update AUTHORS
Yay, we gained a new author, thanks Anton.
Floris Bruynooghe [Sun, 14 Jun 2020 15:23:19 +0000 (17:23 +0200)]
Support aborting the atomic context
Since it is possible to use an atomic context to abort a number of
changes support this usage. Because the only way to actually abort
the transaction is to close the database this must also do so.
Amended by db: Note the limitation requiring close is a limitation of
the underlying notmuch API, which should be fixed in a future notmuch
release.
Floris Bruynooghe [Mon, 15 Jun 2020 20:58:50 +0000 (22:58 +0200)]
Make messages returned by Thread objects owned
This reverses the logic of StandaloneMessage to instead create a
OwnedMessage. Only the Thread class allows retrieving messages more
then once so it can explicitly create such messages.
The added test fails with SIGABRT without the fix for the message
re-use in threads being present.
Anton Khirnov [Mon, 15 Jun 2020 20:58:49 +0000 (22:58 +0200)]
python/notmuch2: do not destroy messages owned by a query
Any messages retrieved from a query - either directly via
search_messages() or indirectly via thread objects - are owned by that
query. Retrieving the same message (i.e. corresponding to the same
message ID / database object) several times will always yield the same
C object.
The caller is allowed to destroy message objects owned by a query before
the query itself - which can save memory for long-lived queries.
However, that message must then never be retrieved again from that
query.
The python-notmuch2 bindings will currently destroy every message object
in Message._destroy(), which will lead to an invalid free if the same
message is then retrieved again. E.g. the following python program leads
to libtalloc abort()ing:
import notmuch2
db = notmuch2.Database(mode = notmuch2.Database.MODE.READ_ONLY)
t = next(db.threads('*'))
msgs = list(zip(t.toplevel(), t.toplevel()))
msgs = list(zip(t.toplevel(), t.toplevel()))
Fix this issue by creating a subclass of Message, which is used for
"standalone" message which have to be freed by the caller. Message class
is then used only for messages descended from a query, which do not need
to be freed by the caller.
Floris Bruynooghe [Mon, 15 Jun 2020 21:55:53 +0000 (23:55 +0200)]
python config access: fix style and KeyError bug
This fixes some minor style/pep8 things and adds tests for the new
config support. Also fixes a bug where KeyError was never raised
on a missing key.