]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/LeiUp.pm
get rid of unnecessary bytes::length usage
[public-inbox.git] / lib / PublicInbox / LeiUp.pm
index 9069232b4b616e99a50027b40d56bf4db51fe4f6..85efd9f5ded69c69341332566d61d2a1f8f6466e 100644 (file)
@@ -42,12 +42,14 @@ sub up1 ($$) {
        }
        $lei->{lss} = $lss; # for LeiOverview->new
        my $lxs = $lei->lxs_prepare or return;
-       $lei->ale->refresh_externals($lxs);
+       $lei->ale->refresh_externals($lxs, $lei);
        $lei->_start_query;
 }
 
 sub up1_redispatch {
        my ($lei, $out, $op_p) = @_;
+       require PublicInbox::LeiFinmsg;
+       $lei->{fmsg} //= PublicInbox::LeiFinmsg->new($lei->{2});
        my $l = bless { %$lei }, ref($lei);
        $l->{opt} = { %{$l->{opt}} };
        delete $l->{sock};
@@ -57,15 +59,16 @@ sub up1_redispatch {
                up1($l, $out);
                $l->qerr("# $out done");
        };
-       $l->err($@) if $@;
+       $l->child_error(1 << 8, $@) if $@;
 }
 
 sub lei_up {
-       my ($lei, $out) = @_;
+       my ($lei, @outs) = @_;
        $lei->{lse} = $lei->_lei_store(1)->search;
        my $opt = $lei->{opt};
-       $opt->{save} = -1;
+       my @local;
        if (defined $opt->{all}) {
+               return $lei->fail("--all and @outs incompatible") if @outs;
                length($opt->{mua}//'') and return
                        $lei->fail('--all and --mua= are incompatible');
 
@@ -74,7 +77,20 @@ sub lei_up {
                $opt->{all} eq 'local' or return
                        $lei->fail('only --all=local works at the moment');
                my @all = PublicInbox::LeiSavedSearch::list($lei);
-               my @local = grep(!m!\Aimaps?://!i, @all);
+               @local = grep(!m!\Aimaps?://!i, @all);
+       } else {
+               @local = @outs;
+       }
+       if (scalar(@outs) > 1) {
+               length($opt->{mua}//'') and return $lei->fail(<<EOM);
+multiple outputs and --mua= are incompatible
+EOM
+               # TODO:
+               return $lei->fail(<<EOM) if grep(m!\Aimaps?://!i, @outs);
+multiple destinations only supported for local outputs (FIXME)
+EOM
+       }
+       if (scalar(@local) > 1) {
                $lei->_lei_store->write_prepare($lei); # share early
                # daemon mode, re-dispatch into our event loop w/o
                # creating an extra fork-level
@@ -89,7 +105,7 @@ sub lei_up {
                $lei->event_step_init;
                $op_c->{ops} = { '' => [$lei->can('dclose'), $lei] };
        } else {
-               up1($lei, $out);
+               up1($lei, $local[0]);
        }
 }