about summary refs log tree commit homepage
path: root/lib/PublicInbox/LeiUp.pm
DateCommit message (Collapse)
2021-11-09lei q|up: fix saved searches for single-phrase search
`"' (double-quote) needs to be quoted for stdin searches. We also need to differentiate between "lei q --stdin" usage when calling "lei up", do it by setting an internal "rawstr" knob to ensure we can parse the config properly regardless of whether the initial search used --stdin or not.
2021-11-02lei: simplify common LeiInput users with ->wq1_start
This method replaces a common pattern of starting workers, preparing internal auth ops, and asynchronous waiting of command completion. It also adds missing LeiAuth support to rediff and rm which rarely need auth.
2021-10-22lei forget-search: support --prune=<local|remote>
Instead of: lei forget-search $OUTPUT && rm -r $OUTPUT we'll also allow a user to do: rm -r $OUTPUT && lei forget-search --prune This gives users flexibility to choose whatever flow is most natural to them.
2021-10-19lei up: support --exclude=, --no-(external|remote|local)
These can be used to temporarily disable using certain externals in case of temporary network failure or mount point unavailability.
2021-10-19lei up: propagate redispatch_all failure via exit code
We can still continue with some local externals, maybe; but the error needs to be propagated to the calling process for scripting purposes.
2021-10-19lei: use die for external and query handling
This allows "lei up" to continue processing unrelated externals if on output fails.
2021-10-19lei up: prefix `remote' and `local' with `o_'
This will help distinguish between mail outputs and external public-inboxes.
2021-10-15lei + ipc: simplify process reaping
Simplify our APIs and force dwaitpid() to work in async mode for all lei workers. This avoids having lingering zombies for parallel searches if one worker finishes soon before another. The old distinction between "old" and "new" workers was needlessly complex, error-prone, and embarrasingly bad. We also never handled v2:// writers properly before on Ctrl-C/Ctrl-Z (SIGINT/SIGTSTP), so add them to @WQ_KEYS to ensure they get handled by $lei when appropropriate.
2021-10-15lei up --all: send signals to workers, receive errors
The redispatch mechanism wasn't routing signals and messages between redispatched workers and script/lei properly. We now rely on PktOp to do bidirectional message forwarding and carefully avoiding circular references by using PktOp.
2021-10-15lei up: actually rely on DESTROY for --alllll
We need to use DESTROY here to ensure we wait for workers, too; not just the initial dispatch. Fixes: cafbd77b3c82167d ("lei up: avoid excessively parallel --all")
2021-10-13lei up --all: show output for warnings
This helps users make sense of which saved searches some warnings were coming from. Since I often create and discard externals, some warnings from saved searches were confusing to me without output context: "`$FOO' is unknown" "$FOO not indexed by Xapian"
2021-09-27config: get_1: use full parameter name
Instead of passing the prefix section and key separately, pass them together as is commonly done with git-config(1) usage as well as our ->get_all API. This inconsistency in the get_1 API is a needless footgun and confused me a bit while working on "lei up" the other week.
2021-09-22lei up: avoid excessively parallel --all
We shouldn't dispatch all outputs right away since they can be expensive CPU-wise. Instead, rely on DESTROY to trigger further redispatches. This also fixes a circular reference bug for the single-output case that could lead to a leftover script/lei after MUA exit. I'm not sure how --jobs/-j should work when the actual xsearch and lei2mail has it's own parallelism ("--jobs=$X,$M"), but it's better than having thousands of subtasks running. Fixes: b34a267efff7b831 ("lei up: fix --mua with single output")
2021-09-21lei q: improve --limit behavior and progress
Avoid slurping gigantic (e.g. 100000) result sets into a single response if a giant limit is specified, and instead use 10000 as a window for the mset with a given offset. We'll also warn and hint towards about the --limit= switch when the estimated result set is larger than the default limit.
2021-09-18lei up: automatically use dt: for remote externals
Since we can't use maxuid for remote externals, automatically maintaining the last time we got results and appending a dt: range to the query will prevent HTTP(S) responses from getting too big. We could be using "rt:", but no stable release of public-inbox supports it, yet, so we'll use dt:, instead. By default, there's a two day fudge factor to account for MTA downtime and delays; which is hopefully enough. The fudge factor may be changed per-invocation with the --remote-fudge-factor=INTERVAL option Since different externals can have different message transport routes, "lastresult" entries are stored on a per-external basis.
2021-09-14lei up: fix env/cwd mismatches with multiple folders
By moving %ENV localization and fchdir into ->dispatch, we can maintain a consistent environment across multiple dispatches while having different clients.
2021-09-13lei up: fix --mua with single output
Oops :x Fixes: b584a53f053a7629 ("lei up: support --all for IMAP folders")
2021-09-13lei up: localize %ENV in redispatch
We need to restore %ENV of script/lei in case another lei client has a different %ENV than what daemon has.
2021-09-09lei up: print messages before disconnecting
Closing the socket for script/lei needs to be done AFTER the final message(s) are printed.
2021-09-07lei up: support --all for IMAP folders
Since "lei up" is expected to be a heavily-used command, better support for IMAP seems like a reasonable idea. This is inefficient since we waste an IMAP(S) TCP connection since it dies when an auth-only LeiUp worker process dies, but it's better than not working at all, right now.
2021-09-03lei up --all: avoid double-close on shared STDOUT
This is merely to avoid perl setting errors internally which were not user visible. The double-close wasn't a problem in practice since we open a new file hanlde for the mbox or mbox.gz anyways, so the new t/lei-up.t test case shows no regressions nor fixes.
2021-09-03lei: ->child_error less error-prone
I was calling "child_error(1, ...)" in a few places where I meant to be calling "child_error(1 << 8, ...)" and inadvertantly triggering SIGHUP in script/lei. Since giving a zero exit code to child_error makes no sense, just allow falsy values to default to 1 << 8.
2021-08-25lei up: improve --all=local stderr output
The "# $NR written to $DEST ($total matches)" messages are arguably the most useful output of "lei up --all=local", but they get intermixed with progress messages from various workers. Queue up these finalization messages and only spit them out on ->DESTROY.
2021-08-19lei q: make --save the default
Since "lei up" is more often useful than not and incurs neglible overhead; enable --save by default and allow --no-save to work. This also fixes a long-standing when overwriting --output destinations with saved searches: dedupe data from previous searches are reset and no longer influences the new (changed) search, so results no longer go missing if two sequential invocations of "lei q --save" point to the same --output.
2021-08-13lei up: note errors if one output destination fails
We can keep going if one (out of multiple) output destinations fail, but the error needs to be communicated to the caller as an exit code.
2021-08-13lei up: support multiple output folders w/o --all=local
Being able to update 1 folder, or all (local) folders is sometimes too limiting, so just allow updating any subset of local folders.
2021-08-11lei: attempt to canonicalize away "/../" pathnames
As documented, File::Spec->canonpath does not canonicalize "/../". While we want to do our best to preserve symlinks in pathnames, leaving "/../" can mislead our inotify|kqueue usage.
2021-05-26lei: require Socket::MsgHdr or Inline::C, drop oneshot
The cost of supporting separate code paths between oneshot and daemon isn't worth the trouble; especially if there are more users to support. The test suite time nearly doubles with oneshot, so that's hurting developer productivity. FD passing is currently required to work efficiently with remote HTTP(S) queries which return large messages, as seen in commit 708b182a57373172f5523f3dc297659d58e03b58 ("ipc: wq: handle >MAX_ARG_STRLEN && <EMSGSIZE case"). Additionally, upcoming support for IMAP IDLE and inotify-based monitoring of Maildirs cannot work properly without a background daemon.
2021-04-30lei import: support shell completion of known folders
This also fixes completion of "lei up" for IMAP folders.
2021-04-23lei: saved searches support --dedupe=<mid|oid>
This is less surprising in case users are used to using --dedupe= without --save.
2021-04-20lei up: support --all=local
Users may wish to update several saved searches at once. We can support parallel updates in lei-daemon so users won't have to do it themselves via xargs or similar. Supporting IMAP outputs would be significantly more involved since we'd have to pre-authenticate for every single IMAP output before entering the redispatch loop.
2021-04-20lei up: more error checking for config loading
We'll support editing the saved search config file, so user errors may happen and we need to throw sensible errors in that case.
2021-04-20config: favor ->get_all when possible
It's slightly less code.
2021-04-19lei_saved_search: split "lei q --save" and "lei up" init paths
They're more different than alike, and having two separate methods seems less confusing to me.
2021-04-19lei q: implement import-before default for --save
This makes "lei q --save" as safe as "lei q" to prevent against accidental data loss when clobbering an existing output,
2021-04-18lei ls-search: command to list saved searches
Going forward, we'll probably support JSON for all the "ls-*" subcommands. This also provides the basis for "lei up" shell completion.
2021-04-17lei q --save: avoid lei.q.format
It is redundant since we stuff everything into the lei.q.output config key.
2021-04-17lei up: support output destination as arg
Specifying a directory in ~/.local/share/lei/saved-searches/ is painful, so support (and start encouraging) the use of the output.
2021-04-13lei: add "lei up" to complement "lei q --save"
The command isn't finalized, yet, but it's intended to update an existing saved search.