about summary refs log tree commit homepage
path: root/lib/PublicInbox/LeiBlob.pm
DateCommit message (Collapse)
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-13treewide: use warn() or carp() instead of env->{psgi.errors}
Large chunks of our codebase and 3rd-party dependencies do not use ->{psgi.errors}, so trying to standardize on it was a fruitless endeavor. Since warn() and carp() are standard mechanism within Perl, just use that instead and simplify a bunch of existing code.
2021-10-13lei: use standard warn() in more places
warn() is easier to augment with context information, and frankly unavoidable in the presence of 3rd-party libraries we don't control.
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-18lei: add ->lms shortcut for LeiMailSync
We access this read-only in many places (and will in more), so provide a shortcut to simplify callers.
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-06-08lei: generalize auxiliary WQ handling
op_wait_event is now more lei-specific since we no longer have to care about oneshot and use a synchronous loop. {ikw} (import-keywords) started a trend, but LeiPmdir (parallel Maildir) is an upcoming WQ class that will follow this idea. Eventually, {l2m} usage may be updated to follow this, too.
2021-05-04lei index: new command to index mail w/o git storage
Since completely purging blobs from git is slow, users may wish to index messages in Maildirs (and eventually other local storage) without storing data in git. Much code from LeiImport and LeiInput is reused, and a new dummy FakeImport class supplies a non-storing $im->add and minimize changes to LeiStore. The tricky part of this command is to support "lei import" after a message has gone through "lei index". Relying on $smsg->{bytes} == 0 (as we do for external-only vmd storage) does not work here, since it would break searching for "z:" byte-ranges when not using externals. This eventually required PublicInbox::Import::add to use a SharedKV to keep track of imported blobs and prevent duplication.
2021-05-03lei: simplify workers_start API
In most cases, we just name the worker process based on the command. The only change is for LeiMirror vs "lei add-external --mirror", but I doubt it matters.
2021-04-28lei: simple WQ workers use {wq1} field
This lets us share more code and reduces cognitive overhead when it comes to picking names (because {lsss} was ridiculous). We'll need to ensure the first error set in lei is the actual error we exit with, otherwise things can get confusing and errors may get lost.
2021-04-28lei: quiet down Eml-related warnings consistently
"lei import" is probably the only place where it users might care about warnings.
2021-04-27lei: standardize on _lei_wq_eof callback for workers
Simplify our internals a little bit.
2021-04-27lei blob: support retrieving attachments via $OID:$IDX
We'll be supporting some sort of text view for pager or piping to an $EDITOR buffer.
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-13lei blob: quiet "git rev-parse --git-dir" stderr w/o --cwd
This seemed to be causing occasional "make check-run" failures with errors bleeding into other tests.
2021-03-31lei blob: "--mail" disables solver, use --include/only
Assume a user specifying --mail doesn't want to spend cycles reconstructing a blob from a code repo. Also, don't require users to use add-external or a previous -I or --only to ready an external for use with ale.git.
2021-03-29lei blob: cleanup solver tmpdir on failure
$lei->fail sends SIGTERM which prevents the File::Temp::Dir in $solver->{tmp} from being cleaned up, so use $lei->child_error instead.
2021-03-28lei: drop coderepo placeholders, submodule TODO
"lei blob" supports --git-dir and -C, and checks if the current directory has a git directory associated with it. It will likely support submodules in the future. I'm inclined to believe declaring coderepos in a command-line tool is needless clutter and users will rarely want to search for blobs across different projects when on the command-line.
2021-03-28lei blob: add remote external support
Introduce a new LeiRemote wrapper to provide an internal API which SolverGit expects. This lets us use HTTP/HTTPS endpoints to reconstruct blobs off patches as we would with local endpoints, just more slowly...
2021-03-28lei blob: fail early if no git dirs
This avoids triggering a "BUG:" message in the solver code.
2021-03-28lei blob: support --no-mail switch
It's possible for a abbreviated OID to be resolved unambiguously to an email before we attempt to look at externals via xsearch; so provide a way for a user to force searching coderepos. If hints (--oid-a, --path-a, --path-b) are present, we'll assume --no-mail by default, otherwise we'll assume the user wants to look through mail for a matching blob.
2021-03-28lei blob: dclose if already failed
We must close the socket to trigger pager exit if blob reconstruction fails. Not sure how to test this in the test suite...
2021-03-28lei: simplify PktOp callers
Provide a consistent ->op_wait_event method instead of forcing callers to loop (or not) at each callsite. This also avoid a leak possibility by avoiding circular references.
2021-03-27lei blob: aka "git-show-harder" for blobs
This implements blob reconstruction via SolverGit, emulating the functionality of /$INBOX/$OID/s/ endpoint in PublicInbox::WWW. It uses the current working tree as a coderepo, and accepts any number of --git-dir=$PATH args. Remote externals are not yet supported. v2: use absolute path for git repos