about summary refs log tree commit homepage
path: root/lib
DateCommit message (Collapse)
2021-04-24extindex: --gc: use escape pathnames for SQL LIKE properly
This allows us to handle odd inboxes w/o a newsgroup configured if they also make the strange choice of having backslashes in their path name. Also, ensure we use case-sensitive LIKE, since case-insensitive FSes are not worth supporting.
2021-04-24lei import: keep sync info for Maildir and IMAP folders
We aren't using it, yet, but the plan is to be able to use this information to propagate keyword changes back to IMAP and Maildir folders using some to-be-implemented command. "lei inspect" is a half-baked new command to make testing this change easier. It will be updated to support more SQLite+Xapian introspection duties in the future, including public-inbox things independent of lei.
2021-04-24lei_mail_sync: for bidirectional keyword sync
We'll be using the new class to efficiently propagate keyword changes from lei/store back to Maildir or IMAP folders.
2021-04-24net_reader: imap_each: add UIDVALIDITY to URL arg
This will allow the callback to reliably maintain OID <=> UID mappings between lei/store and the IMAP folder.
2021-04-24URIimap: support ->uidvalidity and ->iuid
These will be useful for keyword synchronization, and perhaps importing a single IMAP message with ->iuid.
2021-04-24t/lei_to_mail: split "lei import" test $HOME directory
"lei import" behavior will may change w.r.t. keyword handling. Use separate $HOME between different test_lei to ensure isolation between the tests.
2021-04-24lei_input: drop outdated comment w.r.t. compression
Followup-to: 49b036771ef3bf45 ("lei_input: support compressed mboxes")
2021-04-23lei import: support adding keywords and labels on import
This saves some work and makes it easier to set volatile metadata on a message at import time.
2021-04-23lei_to_mail: cwd-agnostic Maildir wakeup
Since we don't have *at() syscalls readily available to us, lei-daemon may call ->poke_dst in the wrong relative directory. Despite not having *at() syscalls, we can still capture the "$MAILDIR/cur" directory handle at pre_augment time so we can reliably call futimes(2) on it using the `utime' perlop.
2021-04-23net_reader: restart on first UID when UIDVALIDITY changes
In other words, treat the same IMAP folder with a different UIDVALIDITY as a completely different folder. If the UIDVALIDITY changes, we can start from UID=1 without falling behind or losing data. If the UIDVALIDITY gets reset to a previously known-good message, we can still resume where we left off before the first UIDVALIDITY change. This affects public-inbox-watch and "lei import" One potential downside of this is for rare altid users, but that's mainly intended for NNTP article numbers which are/were often publicized; not IMAP UIDs which are rarely publicized. The other potential downside is bandwidth waste in in the rare case UIDVALIDITY changes while IMAP folder contents remain unchanged. There's no extra storage used due to existing (v1|v2|lei/store) deduplication mechanisms. Before this change, we were matching offlineimap behavior and stopped synching an IMAP folder when its UIDVALIDITY changed. offlineimap behavior made sense for IMAP <=> Maildir synchronization since Maildirs had no sense of UIDVALIDITY and could only rely on name mapping.
2021-04-23lei up: support symlinked pathnames
On my default FreeBSD 11.x system, "/home" is a symlink to "/usr/home", which causes "lei up" path resolution to fail when I use outputs in $HOME. Fall back to a slow path of globbing and matching pathnames based on st_ino+st_dev.
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-22lei: XDG_RUNTIME_DIR=/dev/null disables daemon mode
We'll support this mode of operation for now to quiet down testing of oneshot mode where the daemon doesn't persist.
2021-04-22lei import|convert: drop --no-kw aliases
Supporting --no-keywords and --no-flags aliases is harmful if users end up assuming "keywords:" and "flags:" are valid search prefixes (they're not).
2021-04-22lei import: --incremental default for NNTP and IMAP
No point in burning through bandwidth to import stuff we already saw. All this logic is shared with -watch but uses a different pathname for lei since it's tied to lei/store (and not a public-inbox).
2021-04-22imap_tracker: prepare for use with lei
We'll support nodatacow as we do in other SQLite DBs
2021-04-22lei: flesh out `forwarded' kw support for Maildir and IMAP
Maildir and IMAP can both handle `forwarded'. Ensure we don't lose `forwarded' when reading from stores which do not support it, but ensure we can set it when reading from IMAP and Maildir stores.
2021-04-21lei: share common *done_wait callbacks
Code is the enemy, and there's no need to duplicate things, here. There may be further opportunities along these lines to further deduplicate things...
2021-04-20lei_query: avoid POSIX::lround for older Perls
POSIX.pm shipped with Perl 5.16.3 did not support lround, at least. So just rely on built-in core functions.
2021-04-20test_common: fix xbail for Perl 5.16
Our use of `ref' was triggering ambiguity in older versions of the Perl parser. Reported-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org> Link: https://public-inbox.org/meta/20210420174912.h6d2yv7zu5xr4yfc@nitro.local/
2021-04-20lei edit-search: command to tweak search parameters
This may be useful for users to tweak search parameters. This command is also the reason lei.saved-search is a git-config file rather than JSON.
2021-04-20lei forget-search: new command to forget saved searches
Readers may lose interest in subscription topics. This lets them avoid clutter by forgetting a saved search. This does not and will not destroy the contents of an --output mailbox. In other words, this is similar to unsubscribing from an Atom/RSS feed or NNTP group. I've also decided we won't support 'mv-search', since it'll probably be rarely used and "lei convert" can be used, instead.
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-20lei up: fix help output and ARGV handling
We don't support changing search terms once "lei q --save" is used.
2021-04-19lei q: --save and --augment may be combined
This necessitated fixing pause_dedupe to release the handle used by ->lock_for_scope_fast, but otherwise no changes to the LeiToMail package.
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-19config: git_config_dump blesses
I don't know if it's worth it to sub (or super)class PublicInbox::Config into something more generic for lei, but this change simplifies a good chunk of lei code that reuses the public-inbox config parsing.
2021-04-19lei_saved_search: avoid needless var shadowing
While perl (5.28) doesn't complain about this, it's confusing to my easily-confused mind.
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-19lei: support unlinked/missing saved searches
It's conceivable a user will want to erase all previous results but still rerun/refresh a search to get new results. We probably won't support prune functionality, here, and instead require explicit removal of saved searches.
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-18avoid wrong/needless squote_maybe shortcuts
We'll keep it in PublicInbox::Config for now, since I'm not sure if there's a better place to put it.
2021-04-18lei_saved_search: avoid git-config
Repeated vfork+execv costing us around 20ms on t/lei-q-save.t, so just learn to quote git-config values and write directly to the config file.
2021-04-17lei up: further improve Maildir canonicalization
We want to be able to use "lei up ." when inside a Maildir. We'll also relax Maildir/mbox basenames to be any non-'/' character after converting relative paths to absolute. The old restriction on allowed characters was unnecessary and made it impossible to reliably map "." when used as the sole argument for "lei up".
2021-04-17lei up: fix canonicalization of Maildirs
We always represent --output destination directories with a trailing slash to disambiguate directories from mbox filenames. Therefore, we must use the trailing slash when mapping the destination beck from the lei/saved-search/* directory. "lei up" now relies exclusively on the users --output pathname or URL for updates. This ought to be less confusing since pathnames in ~/.local/store/lei/saved-searches aren't ideal.
2021-04-17lei q: fix MUA spawn after reading query from stdin
Since "lei q" may read queries from stdin, we must reconnect a known terminal before spawning terminal MUAs. Attempt to use stdout as stdin for this purpose, since terminal MUAs tend to expect stdout to be a terminal. Reported-By: Kyle Meyer <kyle@kyleam.com> Link: https://public-inbox.org/meta/87v98klxg3.fsf@kyleam.com/
2021-04-17lei q --save: clobber config file on repeats
A user may wish to clobber/refine existing search parameters by issuing "lei q --save" again. Support that by overwriting the lei.saved-search state file entirely. We continue to preserve over.sqlite3 for deduplication purposes. This way, we don't get something redundant like: [lei] q = term1 q = term2 q = term1 q = term2 q = term3 ...whenever a user wants to refine their search. Instead, we'll just have: [lei] q = term1 q = term2 q = term3 On the second go.
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-17lei: fix rel2abs
We don't want pathnames with "GLOB(0xADD12355)" in them.
2021-04-17lei_query: fix relative path handling on --stdin
Since --stdin could be waiting on user keyboard input or something else slow, we handle it in the event loop. That means other commands can change the working directory of lei-daemon while a query is being trickled to us via stdin. Rearranging query handling internals to delay opening the --output destination in commit 26e0fe73de93f451 meant another command could throw off our --output pathname if it is relative. Fixes: 26e0fe73de93f451 ("lei_query: rearrange internals to capture query early")
2021-04-16test_common: handle '-C' (chdir) spawn option properly
We use it in t/lei-q-save.t, and were inadvertently writing to the worktree. v2: fix -C $DIR with TEST_RUN_MODE=0
2021-04-16lei_to_mail: cast to URIimap object early
NetReader->add_url supports URI-like objects, now. We'll be relying on the canonicalization for LeiSavedSearch.
2021-04-16lei: saved searches keyed only by path/URL and format
We want users to be able to edit and refine the query over time while using the same output destination.
2021-04-16lei: expose share_path as a method
Since saved-searches aren't a part of lei/store, nor could it be considered cache data... (or can it? it is discardable, after all).
2021-04-16lei q: --save preserves relative time queries
Somebody may want a saved search which consistently asks for messages within a rolling time period window. In other words, we want to support using "lei q --save dt:last.week.." and keeps the "dt:last.week.." relative to whenever "lei up" is run. This ensures relative date-time specifications get used in the future rather than converting into an absolute date-time from the initial "lei q" invocation.
2021-04-16search: expand "d:" to "dt:" for precision with approxidate
If a user specifies "d:" with a higher precision than it was traditionally able to handle, switch transparently to "dt:". This lowers the learning curve and improves DWIM-ness. v2: fix "d:YYYYMMDD..$NEEDS_APPROXIDATE" case
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.