]> Sergey Matveev's repositories - public-inbox.git/commitdiff
lei q: disable remote externals if locals exist
authorEric Wong <e@80x24.org>
Sun, 24 Jan 2021 11:46:50 +0000 (04:46 -0700)
committerEric Wong <e@80x24.org>
Sun, 24 Jan 2021 19:45:23 +0000 (15:45 -0400)
--remote should be explicitly enabled if local externals are
present, since users may be offline or on expensive + metered
Internet while traveling.

In the future, --remote will probably default to
caching/memoizing all messages it fetches to increase the
usefulness of --local.

lib/PublicInbox/LEI.pm
lib/PublicInbox/LeiQuery.pm

index 473a28a99ccdc5645e948408cb9d0bf308802030..378113e8446a4179ef1ac78456004541d0b53677 100644 (file)
@@ -83,7 +83,7 @@ sub _config_path ($) {
 our %CMD = ( # sorted in order of importance/use:
 'q' => [ 'SEARCH_TERMS...', 'search for messages matching terms', qw(
        save-as=s output|mfolder|o=s format|f=s dedupe|d=s thread|t augment|a
-       sort|s=s reverse|r offset=i remote local! external! pretty mua-cmd=s
+       sort|s=s reverse|r offset=i remote! local! external! pretty mua-cmd=s
        torsocks=s no-torsocks verbose|v since|after=s until|before=s),
        PublicInbox::LeiQuery::curl_opt(), opt_dash('limit|n=i', '[0-9]+') ],
 
index a7938e8b1406c488c62d56a40b1470c35155bab3..7713902b0e94e72b89d88851f4ff8cc93bb4ca7a 100644 (file)
@@ -24,7 +24,9 @@ sub lei_q {
        # --external is enabled by default, but allow --no-external
        if ($opt->{external} //= 1) {
                my $cb = $lxs->can('prepare_external');
-               $self->_externals_each($cb, $lxs);
+               my $ne = $self->_externals_each($cb, $lxs);
+               $opt->{remote} //= $ne == $lxs->remotes;
+               delete($lxs->{remotes}) if !$opt->{remote};
        }
        my $xj = $lxs->concurrency($opt);
        my $ovv = PublicInbox::LeiOverview->new($self) or return;