]> Sergey Matveev's repositories - public-inbox.git/commitdiff
lei: _lei_cfg: return empty hashref if unconfigured
authorEric Wong <e@80x24.org>
Mon, 22 Feb 2021 11:22:52 +0000 (08:22 -0300)
committerEric Wong <e@80x24.org>
Mon, 22 Feb 2021 22:14:18 +0000 (18:14 -0400)
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
lib/PublicInbox/LeiAuth.pm
lib/PublicInbox/LeiExternal.pm

index 73c9e267b1e4a37ef742f0e56b10d3655f6cf4b9..dd34c66879fd9c4a08f0c9445c9c24d45afd5add 100644 (file)
@@ -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";
index f2cdb0260a766147fd3d08478ad13ad32755f758..5d321be22f337f33282265628a83d890bfed9509 100644 (file)
@@ -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 ],
index 6cc2e671d9eb4d9b789de6a3310fcf77bbfb1319..0cc84ccaec3b6b4823a5cbd260c6687823968b04 100644 (file)
@@ -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 {