From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id EE22D1FA17 for ; Sun, 24 Jan 2021 11:46:55 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 4/9] lei q: disable remote externals if locals exist Date: Sun, 24 Jan 2021 04:46:50 -0700 Message-Id: <20210124114655.12815-5-e@80x24.org> In-Reply-To: <20210124114655.12815-1-e@80x24.org> References: <20210124114655.12815-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: --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 | 2 +- lib/PublicInbox/LeiQuery.pm | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/PublicInbox/LEI.pm b/lib/PublicInbox/LEI.pm index 473a28a9..378113e8 100644 --- a/lib/PublicInbox/LEI.pm +++ b/lib/PublicInbox/LEI.pm @@ -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]+') ], diff --git a/lib/PublicInbox/LeiQuery.pm b/lib/PublicInbox/LeiQuery.pm index a7938e8b..7713902b 100644 --- a/lib/PublicInbox/LeiQuery.pm +++ b/lib/PublicInbox/LeiQuery.pm @@ -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;