Commit Graph

1278 Commits

Author SHA1 Message Date
17b85e8390 test-circular-symlink: loosen test a bit
Work-around some weirdness. No energy to do a root-cause analysis ;)

Fixes #2832.
2025-04-12 00:56:43 +07:00
507ea8e18e mu-sexp: don't require > c++17 2025-03-23 20:22:56 +02:00
44ba631a34 mu-find: implement format=json2
Implement a new experimental json2 format for mu-find, which gets rid of
the ":" prefixes for fields, i.e., "subject" instead of ":subject".
Document it as well.
2025-03-23 19:47:09 +02:00
4cda859eb8 mu-sexp: tighten definition of plistp
In a plist, we also require the first of each two element pairs to start
with ':'

Fixes #2830.
2025-03-23 19:47:09 +02:00
c91e4ef515 mu-sexp: fix c++23 warning for suffix operator
Space between operator"" and _xxx is deprecated.
2025-03-23 19:47:09 +02:00
18092c7ff9 indexer: minor tweaking 2025-02-23 11:39:21 +02:00
cdb619e4f5 Improve performance of index cleanup: use readdir(3), not access(2)
This change makes index cleanup ~4x faster by changing how we
determine whether a file mentioned by the database still exists on
disk.  Previously, we'd call access(2) for each file the database
mentioned.  Doing so produced a lot of system call overhead.  Now, we
read the directory entries of the directories containing the files
whose existence we're checking, build a hash table from what we find,
then do the existence check against this hash table instead of
entering the kernel.

The semantics of the cleanup check do change subtly, however.
Previously, we checked whether the mentioned file was *readable*.
Now we check merely that it exists.  Extant but unreadable files in
maildirs should be rare.

BEFORE:

$ time mu index --lazy-check
lazily indexing maildir /home/dancol/Mail -> store /home/dancol/.cache/mu/xapian
/ indexing messages; checked: 0; updated/new: 0; cleaned-up: 0

real    0m19.310s
user    0m1.803s
sys     0m12.999s

AFTER:

$ time mu --debug index --lazy-check
lazily indexing maildir /home/dancol/Mail -> store /home/dancol/.cache/mu/xapian
- indexing messages; checked: 0; updated/new: 0; cleaned-up: 0

real    0m4.584s
user    0m2.433s
sys     0m2.133s
2025-02-23 11:39:17 +02:00
7baf1bf5e5 mu: remove empty refs + unit-test
Some message can have an _empty_ message-id, e.g. with:
  In-Reply-To: <>
which we weren't filter out.

This would yield and _empty_ Thread-Id, in mu-message.cc

And this would make mu-query believe it had no matches in the first
query, in Query::Private::run_related, and effectively throw away the
results. (Xapian using empty string both for a "not found" result, and
"found an empty string doesn't help either).

So, avoid having an empty reference. Also add a unit-test.

Fixes #2812.
2025-02-13 22:48:03 +02:00
8372be17dd mu-server: more info for mu4e-analyze-last-query
Include the search parameters besides the query.
2025-02-07 23:43:37 +02:00
aad5fc7df5 mu-server: minor cleanups 2025-02-05 21:07:14 +02:00
c0887603c5 guile: avoid body duplication
In message, don't re-fill when unneeded. Add tests.

Fixes #2802.
2025-02-05 21:16:15 +02:00
09965b2d09 test: add unit-tests for related/new/skip-dups
Test the interaction between related/new/skipped-duplicates. Seems to
work as expected.
2025-02-02 11:38:32 +02:00
e2cd37eaf5 mu-info: add example for ref:, thread: 2025-01-13 22:11:58 +02:00
f54e0c0476 mu-query-parser: cosmetic 2025-01-08 22:12:47 +02:00
5f8e0b71f0 server: make parsed queries available to mu4e
Basically, make the "mu find .... --analyze" information available in
mu4e, through a function mu4e-server-last-query.

This is shows the query as the server saw it, as well as the parse
s-expressions. This can be useful to see how some query is interpreted.
2025-01-08 22:12:47 +02:00
dee7e5951c utils-file: add unit-test for expand_file 2024-12-09 19:41:58 +02:00
0e0d4a0cb6 mu-sexp: add -unix output for json tstamps
The json output (for mu-find etc.) just showed the converted sexp
output, including the clumsy emacs-style tstamps (for changed/date).

Add unix timestamps as well, which are easier to work with outside
emacs.

This handles #2770.
2024-12-07 12:14:55 +02:00
646ad2e840 lib/utils: include fmt/xchar.h
Needed for 'join'
2024-12-06 20:14:11 +02:00
8fefc52eee query: add related: combi-field + test
Add a new combination (pseudo) field "related:", which combines
"message-id" and "references"
2024-12-02 11:43:14 +02:00
ed4d0f5e9d tests: add tests for ref: searching 2024-12-01 23:27:32 +02:00
8c7db59972 fields: make combi-fields introspectable
And add the display of combination-fields to 'mu info fields'.
2024-11-30 22:58:15 +02:00
c872efae34 search: make references searchable
Allow searching for message that have the given message-id in
References: or Reply-To:
2024-11-26 11:21:38 +02:00
831deb2364 lib/store-worker: remove
We're not using it.
2024-11-26 11:21:38 +02:00
d5d57b4327 remove non-single-threaded option
Single-threaded is the build-default, and seems to work well enough for
1.12.7, so remove the option to turn it off.

This is because build-options that influence such low-level/core
behavior are a pain to maintain.
2024-11-26 10:27:52 +02:00
b0d8d42dd2 indexer: make lazy check even lazier
In lazy-mode, we were skipping directories that did not change; however,
this didn't help for the case were users received new messages in big
maildirs.

So, add another check where we compare the ctime of message files with
the time of the last indexing operation. If it's smaller, ignore the
message-file. This is faster than having to consult the Xapian database
for each message.

Note that this requires in mu4e:
      (setq mu4e-index-lazy-check t)
or
   --lazy-check
as a parameter for 'mu index'.
2024-11-10 13:47:54 +02:00
fa59040ebc message: treat pcks7::smt::Unknown as encrypted
GMime isn't more specific, so let's assume it's encrypted; better than
nothing.

Fixes #2784.
2024-11-10 11:07:15 +02:00
d2343c6d62 mu-server: try avoiding xapian multi-threaded access
Try to avoid multi-threaded operations with Xapian.

This remove the thread workers during indexing, and avoids the indexing
background thread. So, mu4e has to wait once again during indexing.

We can improve upon that, but first we need to know if it avoids the
problem of issue #2756.
2024-10-08 11:23:04 +03:00
29dc1cea0c Fix typos. 2024-09-22 17:27:18 +00:00
e9ca3ad9f6 scanner: ignore emacs auto-saves
It's better to _not_ have auto-saves for your draft directory, but if
you do, ignore them at least in mu.

It may still trip up mbsync and friends, but not much we can do about
that.

Clean up the implementation a bit as well.
2024-09-03 23:02:35 +03:00
075394b35f lib: use time_t_max for empty datetime
In Mu::parse_date_time, when provided with an empty string, return
time_t_max instead of G_MAXINT64. For systems with a 64-bit time_t, there
is no difference. With a 32-bit time_t it caused a test to fail:

    not ok /utils/date-basic - ERROR:../mu-1.12.4/lib/utils/tests/test-utils.cc:92
    void test_date_basic(): assertion failed
    (parse_date_time(std::get<0>(test), std::get<1>(test)).value_or(-1)
      == std::get<2>(test)): (18446744073709551615 == 2147483647)

This edge case probably only affected the test, as when other parts of
the application call parse_date_time (e.g. mu-server.cc and
mu-query-processor.cc), they check if the input string is empty first.
2024-08-26 14:46:54 +00:00
c28bfe04e1 message: detect top-level smime parts + test
Fixes #2745
2024-08-22 22:34:34 +03:00
687db1aed6 mu-server: cosmetic 2024-08-21 06:19:35 +03:00
407c6ed4d1 xapian-db: improve errors, fix warnings 2024-08-21 06:18:37 +03:00
d7426238bd Update mu-store-worker.hh, remove duplicate ;
Fix gcc warning:
```
mu4e                           pre-build              [26/198] Compiling C++ object lib/libmu.a.p/mu-query-parser.cc.o               34.390111
mu4e                           pre-build              In file included from ../lib/mu-store.hh:34,                                   34.390132
mu4e                           pre-build                               from ../lib/mu-query-parser.hh:25,                            34.390140
mu4e                           pre-build                               from ../lib/mu-query-parser.cc:20:                            34.390146
mu4e                           pre-build              ../lib/mu-store-worker.hh:162:23: warning: extra ‘;’ [-Wpedantic]              34.390152
mu4e                           pre-build                162 |         Store& store_;;                                                34.390166
mu4e                           pre-build                    |                       ^                                                34.390172
mu4e                           pre-build                    |                       -                                                34.390177
mu4e                           pre-build              [27/198] Compiling C++ object lib/libmu.a.p/mu-contacts-cache.cc.o             34.538682
```
2024-08-08 15:47:38 +08:00
f01360ae9f lib: commit to disk after indexing 2024-08-04 22:28:13 +03:00
c6e8f894c1 test_index_move: extend unit test
Double-check the changed values are seen in a newly opened store.
2024-07-27 09:36:15 +03:00
e6fd83d00d logging: reduce debug logging a bit 2024-06-17 21:40:58 +03:00
5bd439271d store-worker: temporarily revert
Of course, after merging some problems come up.
Let's fix those first.

This reverts commit f2f01595a5.
2024-06-05 12:21:24 +03:00
b4ff8d62af server: support doccount data request
So we can update doccount in mu4e after indexing
2024-06-03 21:01:17 +03:00
697d6b6b4f server: pass sexp-commmands through store worker
To ensure all Xapian rw commands happen in the same thread.
2024-06-03 21:01:17 +03:00
f2f01595a5 indexer: use store-worker
Use the store worker (-thread) to do all database modification.

Currently, the "removed" field of Progress is always 0.
2024-06-03 21:01:17 +03:00
cf9c09867f store-worker: implement
store-worker is a thread + async queue to throttle requests to a single thread.
2024-06-03 21:01:11 +03:00
c05b28e761 xapian-db: remove locks, transaction levels
Simplify xapian-db: locks should go elsewhere; transaction level add
too much complication.
2024-06-03 21:01:07 +03:00
626b16a8f1 mu-config: cosmetic 2024-06-01 17:30:16 +03:00
e3ab780413 message: add default ctor
Useful for stuffing messages in async-queues
2024-06-01 17:30:16 +03:00
1e9f772e0a lib: fix batch-size after db creation
Ensure we use the user-specified batch-size immediately after db creation.
2024-06-01 17:30:16 +03:00
aeb6d44172 mu-store/indexer: consume messages from workers
Add store::consume_message, which is like add message but std::move from
the caller such that the messages longer has copies (with
Xapian::Document) on the caller side; this is to avoid threading issues.
2024-05-08 19:11:40 +03:00
ceed832cb9 mu-query: minor cleanups 2024-05-08 00:06:28 +03:00
23941735df logging: rework a bit, maybe support syslog
Seems journal logging fails on NetBSD (no surprise), but has some
unwanted/not-fully-understood side-effects.

In any case, outside Linux there's no use in even trying to use
journald; so we don't do that anymore.

Add conditional support for syslog (requires glib 2.80).
2024-05-07 09:27:50 +03:00
5a1ca77b47 scanner: don't skip directory entries with type DT_UNKNOWN
According to the readdir(2) man-page, not all file-systems support returning the
entry's file-type in `d_type`.  For example, the reprotest reproducibility tool,
uses the disorderfs FUSE file-system to shuffle the order in which directory
entries are returned, and this does not set `d_type`.  Therefore, in addition to
entries with type `DT_DIR` and `DT_LNK`, also process entries with type
`DT_UNKNOWN`.

Signed-off-by: Jeremy Sowden <azazel@debian.org>
2024-05-01 20:43:18 +01:00