X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=lib%2FPublicInbox%2FLeiInspect.pm;h=d7775d4b616203dd682984422352be6f11688906;hb=1c3e60b66e01df89afdf74990a849a5a7386f9c7;hp=590dfdabca566ef1e37e29a472ba09c9a6bc76d6;hpb=502297d2cda95376b38e7d510f1d34fe89a3ec0e;p=public-inbox.git diff --git a/lib/PublicInbox/LeiInspect.pm b/lib/PublicInbox/LeiInspect.pm index 590dfdab..d7775d4b 100644 --- a/lib/PublicInbox/LeiInspect.pm +++ b/lib/PublicInbox/LeiInspect.pm @@ -12,10 +12,15 @@ use parent qw(PublicInbox::IPC); use PublicInbox::Config; use PublicInbox::MID qw(mids); use PublicInbox::NetReader qw(imap_uri nntp_uri); +use POSIX qw(strftime); +use PublicInbox::LeiOverview; +*iso8601 = \&PublicInbox::LeiOverview::iso8601; sub _json_prep ($) { my ($smsg) = @_; $smsg->{$_} += 0 for qw(bytes lines); # integerize + $smsg->{dt} = iso8601($smsg->{ds}) if defined($smsg->{ds}); + $smsg->{rt} = iso8601($smsg->{ts}) if defined($smsg->{ts}); +{ %$smsg } # unbless and scalarize } @@ -143,8 +148,10 @@ sub inspect_num ($$) { my $ent = { num => $num }; if (defined(my $dir = $lei->{opt}->{dir})) { $ibx = dir2ibx($lei, $dir) or return; - $ent->{xdb} = $ibx->xdb and # for inspect_docid - $docid = PublicInbox::LeiSearch::num2docid($ibx, $num); + if (my $srch = $ibx->search) { + $ent->{xdb} = $srch->xdb and + $docid = $srch->num2docid($num); + } } elsif ($lei->{lse}) { $ibx = $lei->{lse}; $lei->{lse}->xdb; # set {nshard} for num2docid @@ -240,7 +247,7 @@ sub inspect_start ($$) { $lei->{wq1} = $self; $lei->wait_wq_events($op_c, $ops); $self->wq_do('inspect_argv'); - $self->wq_close(1); + $self->wq_close; } sub ins_add { # InputPipe->consume callback @@ -287,4 +294,10 @@ sub _complete_inspect { # TODO: message-ids?, blobs? could get expensive... } +sub ipc_atfork_child { + my ($self) = @_; + $self->{lei}->_lei_atfork_child; + $self->SUPER::ipc_atfork_child; +} + 1;