X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=lib%2FPublicInbox%2FLeiLcat.pm;h=8d89cb7303f2b081b8005daea1dfdf2875f1747b;hb=refs%2Fheads%2Fmaster;hp=c13e2153e88da0daa5b87d8978d85fff1d89a3ee;hpb=8b91bd5f929bf166ee3a79dec43fba0e68b1dc8e;p=public-inbox.git
diff --git a/lib/PublicInbox/LeiLcat.pm b/lib/PublicInbox/LeiLcat.pm
index c13e2153..8d89cb73 100644
--- a/lib/PublicInbox/LeiLcat.pm
+++ b/lib/PublicInbox/LeiLcat.pm
@@ -1,4 +1,4 @@
-# Copyright (C) 2021 all contributors
+# Copyright (C) all contributors
# License: AGPL-3.0+
# lcat: local cat, display a local message by Message-ID or blob,
@@ -13,7 +13,7 @@ use PublicInbox::MID qw($MID_EXTRACT);
sub lcat_folder ($$;$$) {
my ($lei, $folder, $beg, $end) = @_;
- my $lms = $lei->{-lms_ro} //= $lei->lms // return;
+ my $lms = $lei->{-lms_rw} //= $lei->lms // return;
my $folders = [ $folder ];
eval { $lms->arg2folder($lei, $folders) };
return $lei->child_error(0, "# unknown folder: $folder") if $@;
@@ -31,7 +31,7 @@ sub lcat_folder ($$;$$) {
sub lcat_imap_uri ($$) {
my ($lei, $uri) = @_;
# cf. LeiXSearch->lcat_dump
- my $lms = $lei->{-lms_ro} //= $lei->lms // return;
+ my $lms = $lei->{-lms_rw} //= $lei->lms // return;
if (defined $uri->uid) {
push @{$lei->{lcat_todo}}, $lms->imap_oidhex($lei, $uri);
} elsif (defined(my $fid = $lms->fid_for($$uri))) {
@@ -45,7 +45,7 @@ sub lcat_nntp_uri ($$) {
my ($lei, $uri) = @_;
my $mid = $uri->message; # already unescaped by URI::news
return "mid:$mid" if defined($mid);
- my $lms = $lei->{-lms_ro} //= $lei->lms // return;
+ my $lms = $lei->{-lms_rw} //= $lei->lms // return;
my ($ng, $beg, $end) = $uri->group;
$uri->group($ng);
lcat_folder($lei, $$uri, $beg, $end);
@@ -118,24 +118,21 @@ could not extract Message-ID from $x
}
}
- delete $lei->{-lms_ro};
+ delete $lei->{-lms_rw};
@q ? join(' OR ', @q) : $lei->fail("no Message-ID in: @argv");
}
sub _stdin { # PublicInbox::InputPipe::consume callback for --stdin
my ($lei) = @_; # $_[1] = $rbuf
- if (defined($_[1])) {
- $_[1] eq '' and return eval {
- $lei->fchdir or return;
- my @argv = split(/\s+/, $lei->{mset_opt}->{qstr});
- $lei->{mset_opt}->{qstr} = extract_all($lei, @argv)
- or return;
- $lei->_start_query;
- };
- $lei->{mset_opt}->{qstr} .= $_[1];
- } else {
- $lei->fail("error reading stdin: $!");
- }
+ $_[1] // return $lei->fail("error reading stdin: $!");
+ return $lei->{mset_opt}->{qstr} .= $_[1] if $_[1] ne '';
+ eval {
+ $lei->fchdir;
+ my @argv = split(/\s+/, $lei->{mset_opt}->{qstr});
+ $lei->{mset_opt}->{qstr} = extract_all($lei, @argv) or return;
+ $lei->_start_query;
+ };
+ $lei->fail($@) if $@;
}
sub lei_lcat {
@@ -144,9 +141,8 @@ sub lei_lcat {
$lei->ale->refresh_externals($lxs, $lei);
$lei->_lei_store(1);
my $opt = $lei->{opt};
- my %mset_opt = map { $_ => $opt->{$_} } qw(threads limit offset);
+ my %mset_opt;
$mset_opt{asc} = $opt->{'reverse'} ? 1 : 0;
- $mset_opt{limit} //= 10000;
$opt->{sort} //= 'relevance';
$mset_opt{relevance} = 1;
$lei->{mset_opt} = \%mset_opt;