Commit graph

6644 commits

Author SHA1 Message Date
David Bremner
1be79fff50 lib/open: factor out the second half of n_d_open_with_config
The idea is to allow reuse in n_d_create_with_config. This is
primarily code movement, with some changes in error messages to reduce
the number of input parameters.
2021-03-20 07:30:39 -03:00
David Bremner
cba540d6f5 lib/open: reuse directory checks from n_d_c_with_config
Make checks more uniform between creating new databases and opening
existing ones.
2021-03-20 07:24:59 -03:00
David Bremner
82aa3f4d27 lib/open: factor out library initialization
This is slightly more tidy, but more importantly it allows for re-use
of this code in n_d_create_with_config. That re-use will be crucial
when we no longer call n_d_open_with_config from
n_d_create_with_config.
2021-03-20 07:24:24 -03:00
David Bremner
6251e2bb9e lib: remove "path" from notmuch struct
This removes duplication between the struct element and the
configuration string_map entry. Create a simple wrapper for setting
the database path that makes sure the trailing / is stripped.
2021-03-20 07:23:40 -03:00
David Bremner
1383481d4a lib/open: allocate notmuch_t struct early
This gives more flexibility in restructuring the database opening
code.
2021-03-20 07:21:26 -03:00
David Bremner
793d4305d3 lib/open: support NOTMUCH_DATABASE environment variable
The additional code is trivial, but making sure we get the priority of
various options correct takes a few tests.
2021-03-19 22:06:44 -03:00
David Bremner
6e6c319c26 CLI/show: complete conversion to new configuration framework.
In order to open the database in main() for this command, we may need
to re-open it in the (possibly less common) case where crypto options
require write access.
2021-03-19 22:06:19 -03:00
David Bremner
a9f74aeeb9 CLI/new: drop the write lock to run the pre-new hook.
This fixes a bug reported in [1]. In principle it could be possible
avoid one of these reopens, but it complicates the logic in main with
respect to creating new databases.

[1]: id:9C1993DF-84BD-4199-A9C8-BADA98498812@bubblegen.co.uk
2021-03-18 22:58:02 -03:00
David Bremner
7d286f0272 test: Add tests for write access to database from hooks.
Recent changes to configuration handling meant the pre-new hook was
run while the database was open read only, limiting what could be done
in the hook. Add some known broken tests for this problem, as well as
a regression test for write access from the post-new hook.
2021-03-18 22:54:13 -03:00
David Bremner
13efbd0e1c lib: support reopening databases for write access.
In the future Xapian will apparently support this more conveniently
for the cases other than READ_ONLY => READ_ONLY

Conceptually this function seems to fit better in lib/open.cc;
database.cc is still large enough that moving the function makes
sense.
2021-03-18 08:04:06 -03:00
David Bremner
f0717aa380 lib: save path of xapian database in notmuch struct.
This will allow re-opening in a different mode (read/write
vs. read-only) with current Xapian API. It will also prove useful when
updating the compact functions to support more flexible database
location.
2021-03-18 08:03:48 -03:00
David Bremner
1121299905 lib: publish API for notmuch_database_reopen
Include the (currently unused) mode argument which will specify which
mode to re-open the database in. Functionality and docs to be
finalized in a followup commit.
2021-03-18 08:03:36 -03:00
David Bremner
9a5406cc94 test/setup: add check for config exists, but no database.
This code path is not currently tested, and will need updating if the
location of the xapian database changes.
2021-03-18 08:03:19 -03:00
David Bremner
dcd4df2cc0 test: add known broken test for long directory bug
In [1] Gregor Zattler explained the results of his hard work
tracking down a bug in notmuch with long directories. This test
duplicates the bug.

[1]: id:20210317194728.GB5561@no.workgroup
2021-03-18 07:57:38 -03:00
David Bremner
6967dcbb02 lib/open: free GKeyFile
This fixes a small-to-medium (depending on size of config file) memory
leak.
2021-03-13 09:02:36 -04:00
David Bremner
50092a0375 lib/config: free memory from traversing GKeyFile
This fixes a few small memory leaks.
2021-03-13 09:01:51 -04:00
David Bremner
6d5deb76ca lib/open: free value from g_key_file_get_value
This fixes a small memory leak.
2021-03-13 08:58:21 -04:00
David Bremner
12301392d4 lib/open: use local talloc context in n_d_create_with_config
This better matches the memory allocation semantics in
notmuch_database_open_with_config.
2021-03-13 08:49:49 -04:00
uncrustify
eef21c2847 cli: run uncrustify
This is the result of running

     $ uncrustify --replace --config devel/uncrustify.cfg *.c *.h

in the top level source directory

Line breaks were then adjusted manually to keep argc and argv
together.
2021-03-13 08:45:34 -04:00
uncrustify
df4c66f85d test: run uncrustify
This is the result of running:

    $ uncrustify --replace --config ../devel/uncrustify.cfg *.cc *.c *.h

in the test directory.
2021-03-13 08:45:34 -04:00
uncrustify
0756d25872 util: run uncrustify
This is the result of running

     $ uncrustify --replace --config ../devel/uncrustify.cfg *.c *.h

in the util directory
2021-03-13 08:45:34 -04:00
uncrustify
8aeba1228a lib: run uncrustify
This is the result of running

     $ uncrustify --replace --config ../devel/uncrustify.cfg *.c *.h *.cc

in the lib directory
2021-03-13 08:45:34 -04:00
David Bremner
97fadd0645 test: clean up some extra whitespace.
The extra space is mainly just untidy.
2021-03-12 07:19:14 -04:00
Tomi Ollila
d12d91f828 test: T020-compact.sh: fix work directory location
Fix use of $TEST_DIRECTORY ($NOTMUCH_BUILDDIR/test/) with use of
$TMP_DIRECTORY ($NOTMUCH_BUILDDIR/test/tmp.T020-compact/ in case
of T020-compact.sh) as root directory where to write test files
and directories.
2021-03-12 07:16:01 -04:00
David Bremner
324443f166 devel/uncrustify: add line length limits.
A generous limit of 102 is chosen to moderate the amount of resulting
reformatting.
2021-03-12 07:15:41 -04:00
David Bremner
4c79a2dabe notmuch 0.31.4 release
-----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEEkiyHYXwaY0SiY6fqA0U5G1WqFSEFAmAuVjQACgkQA0U5G1Wq
 FSG6RA//bDdAtsG7QlywGONVX1FOSHxAgppDVRvSDXuluPmGgWvc2T80awbonfT5
 AHy9co41L9484QbOzd29d9Ttu5O39JdQbo+DCAJ6y2vm1M1dLCZw3HXaZGfxoUZo
 9L9Agxg/rYIEso7dAehOs3rGsia46aj2MDCVCUuA4DkVFhkbQ2QidIH+l3VPdYqm
 +1XmuJwyftO7hMifFd9W9ifO9wrBcK9WtJ23feufMhqfBsS0ItLysOhZQx+QdxSj
 7GuA6qX6V7XlIWpdohIOMKmT9tGHMDUo6Qk5m8aSc2XmKAybAXRc+qr0Kg8EpvBF
 1d9SqNptcXQL6rORJxluXR/aCuCb7m8YDgxFVSrFcp/M/twbpDC3WzjmAV+RZpDP
 GBKDH06IGaOMOj9GaYYWCe9loGROzOIT4y04Ckukit0AWpmdbaKnkAkPdrxrMWEu
 a5v5KkkMYT42q0PFU5bDjwvq+8Afmzt7oMO72zXz0mfuFNtFzZCUN/AG9LtHoRfk
 Q2ks/xBppmtCxWRAHVWc7f+Gk1OzI2PLVWnXIe9gxGimSpgT2QPUvZcxLHT/XWD5
 XRrrxtkPjKB1v6tWOFEMPI6WxE1iBzoC9AdG2h48ZP5drlLObcAxhAg5AvHJGJSr
 8D4iSa9cKjHD6qxDSXChzF6BF4aDNhF2Flq9Cs9tZb8nyt+Ix18=
 =mAE/
 -----END PGP SIGNATURE-----

Merge tag '0.31.4'

notmuch 0.31.4 release
2021-02-18 08:47:53 -04:00
David Bremner
3a3208bb7b debian: drop patches
we should by synced up with the tarball again
2021-02-18 07:55:28 -04:00
David Bremner
346b999ae6 doc: bump copyright year 2021-02-18 07:55:28 -04:00
David Bremner
9f2796438f debian: changelog for 0.31.4-1 2021-02-18 07:55:28 -04:00
David Bremner
42b2201c11 NEWS: news for 0.31.4 2021-02-18 07:55:28 -04:00
David Bremner
2ab95d813c version: update to 0.31.4 2021-02-18 07:17:22 -04:00
David Bremner
a37d5f5976 test: Fix race condition in T568-lib-thread.sh
The assignment of thread-ids is (apparently) non-deterministic in a
way that mostly seems to show up on multicore machines. In my tests
the number is different from that previously assumed by this test
about 15% of the time on a 50 thread (25 core) Xeon.

Since message id's are fixed, use a message known to be in the thread
of interest to pick out the correct thread-id.
2021-02-18 07:15:47 -04:00
David Bremner
6db8b422d9 fix build failure with glib 2.67
Based on a patch from Michael J Gruber [1].  As of glib 2.67 (more
specifically [2]), including "gmime-extra.h" inside an extern "C"
block causes build failures, because glib is using C++ features.

Observing that "gmime-extra.h" is no longer needed in
notmuch-private.h, which can simply delete that include, but
we have to correspondingly move the includes which might include
it (in particular crypto.h) out of the extern "C" block also.

This seems less fragile than only moving gmime-extra, and relying on
preprocessor sentinels to keep the deeper includes from happening.

Move to the include to the outside of the extern block.

[1]: id:aee618a3d41f7889a7449aa16893e992325a909a.1613055071.git.git@grubix.eu
[2]: https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1715
2021-02-15 16:43:50 -04:00
Daniel Kahn Gillmor
7061e41cd0 python: convert shebangs to python3
This is the last bit of "python" left in the notmuch codebase.

https://www.python.org/dev/peps/pep-0394/#recommendation encourages
"third-party distributors" to use more-specific shebang lines.  I'm
not certain that the notmuch project itself is a "third-party
contributor" but I think this is a safe way to encourage people to use
python3 when they're developing notmuch.

We already have python3 explicitly elsewhere in the codebase for
developers (in nmbug).

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
2021-02-15 16:32:31 -04:00
David Bremner
1b2ec7578e lib: use a stricter unused macro
This would have caught bugs like the one corrected in the previous commit.
2021-02-14 22:28:55 -04:00
David Bremner
439d1ef814 lib/open: remove incorrect unused attribute
With the current unused macro in lib/notmuch-private.h this seems
harmless, but is misleading, since the parameter is in fact used.
2021-02-14 22:27:51 -04:00
David Bremner
8fb42948a2 lib: add missing private status values.
Many public status values have been added without being copied to the
list of private status values.
2021-02-06 20:01:47 -04:00
David Bremner
d9af0af164 doc: describe new config framework
Remove STORED IN DATABASE discussion, describe search rules.
Currently profiles seem a bit pointless. They will make more sense
when they apply to databases as well.
2021-02-06 19:59:47 -04:00
David Bremner
f61d88c6f4 CLI: use configured hook directory
This enables support for hooks outside the database directory.
It relies strongly on configuration information being usable between
closing the database and destroying it.
2021-02-06 19:57:55 -04:00
David Bremner
0345bc57a0 lib/open: set HOOK_DIR on open
This is a simple two step path search.  Most error checking is
deferred until running the hooks.
2021-02-06 19:56:13 -04:00
David Bremner
4922416ccc lib/config: add HOOK_DIR
The hook directory configuration needs to be kept in synch with the
other configuration information, so add scaffolding to support this at
database opening time.
2021-02-06 19:54:09 -04:00
David Bremner
0d3bef312d cli/new: convert to new config framework
In addition to the same type of changes as converting other
subcommands, add the possibility of creating a database at the top
level. It would probably make sense to use this for insert as well.
2021-02-06 19:52:11 -04:00
David Bremner
5ef731f1aa cli/new: refactor database upgrade code
Move to a separate function. This is essentially just code movement.
2021-02-06 19:50:30 -04:00
David Bremner
ac67cd84ee lib: introduce notmuch_database_create_with_config
This takes a config path parameter, and can use that to decide the
new database location.
2021-02-06 19:48:34 -04:00
David Bremner
55f5e87096 lib: add NOTMUCH_STATUS_DATABASE_EXISTS
It is desirable to distinguish between attempting to create a database
that already exists, and more fatal errors like permission problems.
2021-02-06 19:46:46 -04:00
David Bremner
c447fe92c7 lib/database: move n_d_create* to open.cc
This will help share code with n_d_open_with_config.
2021-02-06 19:45:04 -04:00
David Bremner
eea258c0c9 lib: add NOTMUCH_STATUS_NO_CONFIG
This will allow client code to provide more meaningful diagnostics. In
particular it will enable "notmuch new" to continue suggsting the user
run "notmuch setup" to create a config after "notmuch new" is
transitioned to the new  configuration framework.
2021-02-06 19:43:11 -04:00
David Bremner
1f860a6c41 lib/open: factor out choosing database path
The plan is to share code with a new database creation function that
has a similar API to n_d_open_with_config.
2021-02-06 19:41:28 -04:00
David Bremner
b860be6a76 lib/config: add NOTMUCH_CONFIG_NEW_IGNORE
This will be needed by (at least) the conversion of notmuch-new.c to
the new config framework
2021-02-06 19:39:33 -04:00
David Bremner
baf1202fbc bindings/notmuch2: add missing crypto error status codes
These are needed so that the later codes line up numerically.
2021-02-06 19:37:50 -04:00