]> Sergey Matveev's repositories - public-inbox.git/commitdiff
net_reader: detect IMAP failures earlier
authorEric Wong <e@80x24.org>
Sat, 18 Sep 2021 09:33:29 +0000 (09:33 +0000)
committerEric Wong <e@80x24.org>
Sat, 18 Sep 2021 20:25:30 +0000 (20:25 +0000)
An Mail::IMAPClient object may be returned even on connection
failure, so use IsConnected to check for it.  This ensures
git-credential will no longer prompt for passwords when there's
no connection.

lib/PublicInbox/NetReader.pm

index e703cddb1ce686eadda1823d4428f0db7972bcb3..8eff847e534c63b1a5b154616b49cde55b0fb0ae 100644 (file)
@@ -108,7 +108,8 @@ sub mic_for ($$$$) { # mic = Mail::IMAPClient
        };
        $mic_arg->{Ssl} = 1 if $uri->scheme eq 'imaps';
        require PublicInbox::IMAPClient;
-       my $mic = mic_new($self, $mic_arg, $sec, $uri) or
+       my $mic = mic_new($self, $mic_arg, $sec, $uri);
+       ($mic && $mic->IsConnected) or
                die "E: <$uri> new: $@".onion_hint($lei, $uri);
 
        # default to using STARTTLS if it's available, but allow