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 A9F751F9FF for ; Mon, 22 Feb 2021 11:22:59 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 03/10] lei: _lei_cfg: return empty hashref if unconfigured Date: Mon, 22 Feb 2021 08:22:52 -0300 Message-Id: <20210222112259.32402-3-e@80x24.org> In-Reply-To: <20210222112259.32402-1-e@80x24.org> References: <20210222112155.32231-1-e@80x24.org> <20210222112259.32402-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Existing callers in LeiExternal actually depend on this, and LeiAuth shouldn't need to be creating a config file just to do a conversion against an anonymous IMAP server. --- lib/PublicInbox/LEI.pm | 2 +- lib/PublicInbox/LeiAuth.pm | 1 - lib/PublicInbox/LeiExternal.pm | 6 +++--- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/PublicInbox/LEI.pm b/lib/PublicInbox/LEI.pm index 73c9e267..dd34c668 100644 --- a/lib/PublicInbox/LEI.pm +++ b/lib/PublicInbox/LEI.pm @@ -592,7 +592,7 @@ sub _lei_cfg ($;$) { if (!@st) { unless ($creat) { delete $self->{cfg}; - return; + return bless {}, 'PublicInbox::Config'; } my (undef, $cfg_dir, undef) = File::Spec->splitpath($f); -d $cfg_dir or mkpath($cfg_dir) or die "mkpath($cfg_dir): $!\n"; diff --git a/lib/PublicInbox/LeiAuth.pm b/lib/PublicInbox/LeiAuth.pm index f2cdb026..5d321be2 100644 --- a/lib/PublicInbox/LeiAuth.pm +++ b/lib/PublicInbox/LeiAuth.pm @@ -42,7 +42,6 @@ sub auth_eof { sub auth_start { my ($self, $lei, $post_auth_cb, @args) = @_; - $lei->_lei_cfg(1); # workers may need to read config my $op = $lei->workers_start($self, 'auth', 1, { 'net_merge' => [ \&net_merge, $lei ], '' => [ \&auth_eof, $lei, $post_auth_cb, @args ], diff --git a/lib/PublicInbox/LeiExternal.pm b/lib/PublicInbox/LeiExternal.pm index 6cc2e671..0cc84cca 100644 --- a/lib/PublicInbox/LeiExternal.pm +++ b/lib/PublicInbox/LeiExternal.pm @@ -9,7 +9,7 @@ use PublicInbox::Config; sub externals_each { my ($self, $cb, @arg) = @_; - my $cfg = $self->_lei_cfg(0); + my $cfg = $self->_lei_cfg; my %boost; for my $sec (grep(/\Aexternal\./, @{$cfg->{-section_order}})) { my $loc = substr($sec, length('external.')); @@ -234,7 +234,7 @@ sub _complete_url_common ($) { # shell completion helper called by lei__complete sub _complete_forget_external { my ($self, @argv) = @_; - my $cfg = $self->_lei_cfg(0); + my $cfg = $self->_lei_cfg; my ($cur, $re) = _complete_url_common(\@argv); # FIXME: bash completion off "http:" or "https:" when the last # character is a colon doesn't work properly even if we're @@ -250,7 +250,7 @@ sub _complete_forget_external { sub _complete_add_external { # for bash, this relies on "compopt -o nospace" my ($self, @argv) = @_; - my $cfg = $self->_lei_cfg(0); + my $cfg = $self->_lei_cfg; my ($cur, $re) = _complete_url_common(\@argv); require URI; map {