unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 5/8] net_reader: imap_opt => cfg_opt
Date: Thu,  9 Sep 2021 05:25:02 +0000	[thread overview]
Message-ID: <20210909052505.7174-6-e@80x24.org> (raw)
In-Reply-To: <20210909052505.7174-1-e@80x24.org>

Since this our internal IMAP options are keyed by URI section,
there's no need to have separate hashes for NNTP and IMAP
options since they URI already distinguishes them.

This will make future changes to support POP3 and JMAP and
arg caching with lei/store easier.
---
 lib/PublicInbox/NetReader.pm | 12 ++++++------
 lib/PublicInbox/Watch.pm     |  4 ++--
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/lib/PublicInbox/NetReader.pm b/lib/PublicInbox/NetReader.pm
index e0a64202..f04752e5 100644
--- a/lib/PublicInbox/NetReader.pm
+++ b/lib/PublicInbox/NetReader.pm
@@ -43,7 +43,7 @@ EOM
 sub mic_new ($$$$) {
 	my ($self, $mic_arg, $sec, $uri) = @_;
 	my %mic_arg = %$mic_arg;
-	my $sa = $self->{imap_opt}->{$sec}->{-proxy_cfg} || $self->{-proxy_cli};
+	my $sa = $self->{cfg_opt}->{$sec}->{-proxy_cfg} || $self->{-proxy_cli};
 	if ($sa) {
 		my %opt = %$sa;
 		$opt{ConnectAddr} = delete $mic_arg{Server};
@@ -292,15 +292,15 @@ sub imap_common_init ($;$) {
 		my $to = cfg_intvl($cfg, 'imap.timeout', $$uri);
 		$mic_args->{$sec}->{Timeout} = $to if $to;
 		my $sa = socks_args($cfg->urlmatch('imap.Proxy', $$uri));
-		$self->{imap_opt}->{$sec}->{-proxy_cfg} = $sa if $sa;
+		$self->{cfg_opt}->{$sec}->{-proxy_cfg} = $sa if $sa;
 		for my $k (qw(pollInterval idleInterval)) {
 			$to = cfg_intvl($cfg, "imap.$k", $$uri) // next;
-			$self->{imap_opt}->{$sec}->{$k} = $to;
+			$self->{cfg_opt}->{$sec}->{$k} = $to;
 		}
 		my $k = 'imap.fetchBatchSize';
 		my $bs = $cfg->urlmatch($k, $$uri) // next;
 		if ($bs =~ /\A([0-9]+)\z/) {
-			$self->{imap_opt}->{$sec}->{batch_size} = $bs;
+			$self->{cfg_opt}->{$sec}->{batch_size} = $bs;
 		} else {
 			warn "$k=$bs is not an integer\n";
 		}
@@ -462,7 +462,7 @@ sub each_old_flags ($$$$) {
 	my ($self, $mic, $uri, $l_uid) = @_;
 	$l_uid ||= 1;
 	my $sec = uri_section($uri);
-	my $bs = ($self->{imap_opt}->{$sec}->{batch_size} // 1) * 10000;
+	my $bs = ($self->{cfg_opt}->{$sec}->{batch_size} // 1) * 10000;
 	my ($eml_cb, @args) = @{$self->{eml_each}};
 	$self->{quiet} or warn "# $uri syncing flags 1:$l_uid\n";
 	for (my $n = 1; $n <= $l_uid; $n += $bs) {
@@ -554,7 +554,7 @@ EOF
 		my $m = $mod ? " [(UID % $mod) == $shard]" : '';
 		warn "# $uri fetching UID $l_uid:$r_uid$m\n";
 	}
-	my $bs = $self->{imap_opt}->{$sec}->{batch_size} // 1;
+	my $bs = $self->{cfg_opt}->{$sec}->{batch_size} // 1;
 	my $req = $mic->imap4rev1 ? 'BODY.PEEK[]' : 'RFC822.PEEK';
 	my $key = $req;
 	$key =~ s/\.PEEK//;
diff --git a/lib/PublicInbox/Watch.pm b/lib/PublicInbox/Watch.pm
index 96faa9f8..20ce0616 100644
--- a/lib/PublicInbox/Watch.pm
+++ b/lib/PublicInbox/Watch.pm
@@ -530,9 +530,9 @@ sub watch_imap_init ($$) {
 	for my $uri (@{$self->{imap_order}}) {
 		my $sec = uri_section($uri);
 		my $mic = $mics->{$sec};
-		my $intvl = $self->{imap_opt}->{$sec}->{pollInterval};
+		my $intvl = $self->{cfg_opt}->{$sec}->{pollInterval};
 		if ($mic->has_capability('IDLE') && !$intvl) {
-			$intvl = $self->{imap_opt}->{$sec}->{idleInterval};
+			$intvl = $self->{cfg_opt}->{$sec}->{idleInterval};
 			push @$idle, [ $uri, $intvl // () ];
 		} else {
 			push @{$poll->{$intvl || 120}}, $uri;

  parent reply	other threads:[~2021-09-09  5:25 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-09  5:24 [PATCH 0/8] net_reader: simplify + fix bugs Eric Wong
2021-09-09  5:24 ` [PATCH 1/8] net_reader: do not set "SSL" fields for non-TLS Eric Wong
2021-09-09  5:24 ` [PATCH 2/8] net_reader: set IMAPClient Keepalive flag late Eric Wong
2021-09-09  5:25 ` [PATCH 3/8] net_reader: preserve memoized IMAPClient arg for SOCKS Eric Wong
2021-09-09  5:25 ` [PATCH 4/8] net_reader: nntp_opt => cfg_opt Eric Wong
2021-09-09  5:25 ` Eric Wong [this message]
2021-09-09  5:25 ` [PATCH 6/8] net_reader: combine Net::NNTP and IMAPClient args Eric Wong
2021-09-09  5:25 ` [PATCH 7/8] net_reader: improve naming of common args Eric Wong
2021-09-09  5:25 ` [PATCH 8/8] net_reader: support Mail::IMAPClient Ignoresizeerrors Eric Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210909052505.7174-6-e@80x24.org \
    --to=e@80x24.org \
    --cc=meta@public-inbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).