about summary refs log tree commit homepage
path: root/lib/PublicInbox/NetReader.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2021-02-22 08:22:53 -0300
committerEric Wong <e@80x24.org>2021-02-22 18:14:19 -0400
commit76689d2b939f3a36db406684b588eb5bec10955b (patch)
tree056b057d491359851b7bbae54b8d784833bb1130 /lib/PublicInbox/NetReader.pm
parent16396c1c2f4968d465ef99a68b3d76d7c1f32628 (diff)
downloadpublic-inbox-76689d2b939f3a36db406684b588eb5bec10955b.tar.gz
Since this only has one worker, we can auth directly in the
worker since the convert worker now has access to the script/lei
{sock} for running "git credential".
Diffstat (limited to 'lib/PublicInbox/NetReader.pm')
-rw-r--r--lib/PublicInbox/NetReader.pm16
1 files changed, 9 insertions, 7 deletions
diff --git a/lib/PublicInbox/NetReader.pm b/lib/PublicInbox/NetReader.pm
index 0956d5da..c29e09c1 100644
--- a/lib/PublicInbox/NetReader.pm
+++ b/lib/PublicInbox/NetReader.pm
@@ -423,14 +423,16 @@ sub _imap_fetch_all ($$$) {
 
 # uses cached auth info prepared by mic_for
 sub mic_get {
-        my ($self, $sec) = @_;
-        my $mic_arg = $self->{mic_arg}->{$sec};
-        unless ($mic_arg) {
-                my $uri = ref $sec ? $sec : PublicInbox::URIimap->new($sec);
-                $sec = uri_section($uri);
-                $mic_arg = $self->{mic_arg}->{$sec} or
-                        die "BUG: no Mail::IMAPClient->new arg for $sec";
+        my ($self, $uri) = @_;
+        my $sec = uri_section($uri);
+        # see if caller saved result of imap_common_init
+        if (my $cached = $self->{mics_cached}) {
+                my $mic = $cached->{$sec};
+                return $mic if $mic && $mic->IsConnected;
+                delete $cached->{$sec};
         }
+        my $mic_arg = $self->{mic_arg}->{$sec} or
+                        die "BUG: no Mail::IMAPClient->new arg for $sec";
         if (defined(my $cb_name = $mic_arg->{Authcallback})) {
                 if (ref($cb_name) ne 'CODE') {
                         $mic_arg->{Authcallback} = $self->can($cb_name);