]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/LeiOverview.pm
get rid of unnecessary bytes::length usage
[public-inbox.git] / lib / PublicInbox / LeiOverview.pm
index 68f6c792d67aad4221f61872b0a0d8585f4e511c..223db22244eca51cf9554c76d685f4625d02e88a 100644 (file)
@@ -76,7 +76,7 @@ sub new {
        $fmt //= $devfd >= 0 ? 'json' : (detect_fmt($lei, $dst) or return);
 
        if (index($dst, '://') < 0) { # not a URL, so assume path
-                $dst = File::Spec->canonpath($dst);
+                $dst = $lei->canonpath_harder($dst);
        } # else URL
 
        my $self = bless { fmt => $fmt, dst => $dst }, $class;
@@ -101,8 +101,6 @@ sub new {
        if ($json) {
                $lei->{dedupe} //= PublicInbox::LeiDedupe->new($lei);
        } else {
-               # default to the cheapest sort since MUA usually resorts
-               $opt->{'sort'} //= 'docid' if $devfd < 0;
                $lei->{l2m} = eval { PublicInbox::LeiToMail->new($lei) };
                return $lei->fail($@) if $@;
                if ($opt->{mua} && $lei->{l2m}->lock_free) {
@@ -110,6 +108,8 @@ sub new {
                        $opt->{alert} //= [ ':WINCH,:bell' ] if -t $lei->{1};
                }
        }
+       return $lei->fail('--shared is only for v2 inbox output') if
+               $self->{fmt} ne 'v2' && $lei->{opt}->{shared};
        $self;
 }
 
@@ -121,7 +121,7 @@ sub ovv_begin {
        } # TODO HTML/Atom/...
 }
 
-# called once by parent (via PublicInbox::EOFpipe)
+# called once by parent (via PublicInbox::PktOp  '' => query_done)
 sub ovv_end {
        my ($self, $lei) = @_;
        if ($self->{fmt} eq 'json') {
@@ -197,7 +197,7 @@ sub _json_pretty {
 }
 
 sub ovv_each_smsg_cb { # runs in wq worker usually
-       my ($self, $lei, $ibxish) = @_;
+       my ($self, $lei) = @_;
        my ($json, $dedupe);
        if (my $pkg = $self->{json}) {
                $json = $pkg->new;
@@ -210,17 +210,11 @@ sub ovv_each_smsg_cb { # runs in wq worker usually
                $dedupe->prepare_dedupe;
        }
        $lei->{ovv_buf} = \(my $buf = '') if !$l2m;
-       if ($l2m && !$ibxish) { # remote https?:// mboxrd
-               my $wcb = $l2m->write_cb($lei);
-               sub {
-                       my ($smsg, undef, $eml) = @_; # no mitem in $_[1]
-                       $wcb->(undef, $smsg, $eml);
-               };
-       } elsif ($l2m && $l2m->{-wq_s1}) {
+       if ($l2m) {
                sub {
-                       my ($smsg, $mitem) = @_;
+                       my ($smsg, $mitem, $eml) = @_;
                        $smsg->{pct} = get_pct($mitem) if $mitem;
-                       $l2m->wq_io_do('write_mail', [], $smsg);
+                       $l2m->wq_io_do('write_mail', [], $smsg, $eml);
                }
        } elsif ($self->{fmt} =~ /\A(concat)?json\z/ && $lei->{opt}->{pretty}) {
                my $EOR = ($1//'') eq 'concat' ? "\n}" : "\n},";