X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=lib%2FPublicInbox%2FLEI.pm;h=833d9c4dde67f2d7c88159c22d6084c8748360db;hb=26c426cf6fd9a3f44f11fa30e4824aeac574a6a0;hp=beeb8b4894f1fcc453867a8e8d4a30c492149161;hpb=59be5c57763a64c04ecbb9a344b60c435a43fb24;p=public-inbox.git diff --git a/lib/PublicInbox/LEI.pm b/lib/PublicInbox/LEI.pm index beeb8b48..833d9c4d 100644 --- a/lib/PublicInbox/LEI.pm +++ b/lib/PublicInbox/LEI.pm @@ -196,6 +196,8 @@ our %CMD = ( # sorted in order of importance/use: 'ls-label' => [ '', 'list labels', qw(z|0 stats:s), @c_opt ], 'ls-mail-sync' => [ '[FILTER]', 'list mail sync folders', qw(z|0 globoff|g invert-match|v local remote), @c_opt ], +'ls-mail-source' => [ 'URL', 'list IMAP or NNTP mail source folders', + qw(z|0 ascii l), @c_opt ], 'forget-external' => [ 'LOCATION...|--prune', 'exclude further results from a publicinbox|extindex', qw(prune), @c_opt ], @@ -381,6 +383,7 @@ my %OPTDESC = ( 'format|f=s ls-search' => ['OUT|json|jsonl|concatjson', 'listing output format' ], 'l ls-search' => 'long listing format', +'l ls-mail-source' => 'long listing format', 'format|f=s ls-external' => $ls_format, 'limit|n=i@' => ['NUM', 'limit on number of matches (default: 10000)' ], @@ -567,6 +570,11 @@ sub pkt_op_pair { $end; } +sub incr { + my ($self, $field, $nr) = @_; + $self->{counters}->{$field} += $nr; +} + sub workers_start { my ($lei, $wq, $jobs, $ops, $flds) = @_; $ops = { @@ -574,6 +582,7 @@ sub workers_start { '|' => [ \&sigpipe_handler, $lei ], 'x_it' => [ \&x_it, $lei ], 'child_error' => [ \&child_error, $lei ], + 'incr' => [ \&incr, $lei ], ($ops ? %$ops : ()), }; $ops->{''} //= [ $wq->can('_lei_wq_eof') || \&wq_eof, $lei ]; @@ -583,8 +592,6 @@ sub workers_start { $wq->wq_workers_start($ident, $jobs, $lei->oldset, $flds); delete $lei->{pkt_op_p}; my $op_c = delete $lei->{pkt_op_c}; - # {-lei_sock} persists script/lei process until ops->{''} EOF callback - $op_c->{-lei_sock} = $lei->{sock}; @$end = (); $lei->event_step_init; ($op_c, $ops); @@ -1092,10 +1099,11 @@ sub event_step { sub event_step_init { my ($self) = @_; - return if $self->{-event_init_done}++; - if (my $sock = $self->{sock}) { # using DS->EventLoop + my $sock = $self->{sock} or return; + $self->{-event_init_done} //= do { # persist til $ops done $self->SUPER::new($sock, EPOLLIN|EPOLLET); - } + $sock; + }; } sub noop {} @@ -1246,6 +1254,12 @@ sub busy { 1 } # prevent daemon-shutdown if client is connected # can immediately reread it sub DESTROY { my ($self) = @_; + if (my $counters = delete $self->{counters}) { + for my $k (sort keys %$counters) { + my $nr = $counters->{$k}; + $self->child_error(1 << 8, "$nr $k messages"); + } + } $self->{1}->autoflush(1) if $self->{1}; stop_pager($self); # preserve $? for ->fail or ->x_it code