* [PATCH 03/11] watch: connect to NNTP and IMAP in config order
2021-02-17 10:06 6% [PATCH 00/11] lei IMAP read support Eric Wong
@ 2021-02-17 10:06 7% ` Eric Wong
0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2021-02-17 10:06 UTC (permalink / raw)
To: meta
This is hopefully less surprising to users when they're prompted
for credentials.
---
lib/PublicInbox/NetReader.pm | 4 ++--
lib/PublicInbox/Watch.pm | 17 ++++++++++++-----
2 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/lib/PublicInbox/NetReader.pm b/lib/PublicInbox/NetReader.pm
index 8c919f66..fa337bcd 100644
--- a/lib/PublicInbox/NetReader.pm
+++ b/lib/PublicInbox/NetReader.pm
@@ -249,7 +249,7 @@ sub imap_common_init ($) {
require PublicInbox::URIimap;
my $cfg = $self->{pi_cfg};
my $mic_args = {}; # scheme://authority => Mail:IMAPClient arg
- for my $url (sort keys %{$self->{imap}}) {
+ for my $url (@{$self->{imap_order}}) {
my $uri = PublicInbox::URIimap->new($url);
my $sec = uri_section($uri);
for my $k (qw(Starttls Debug Compress)) {
@@ -273,7 +273,7 @@ sub imap_common_init ($) {
# make sure we can connect and cache the credentials in memory
$self->{mic_arg} = {}; # schema://authority => IMAPClient->new args
my $mics = {}; # schema://authority => IMAPClient obj
- for my $url (sort keys %{$self->{imap}}) {
+ for my $url (@{$self->{imap_order}}) {
my $uri = PublicInbox::URIimap->new($url);
$mics->{uri_section($uri)} //= mic_for($self, $url, $mic_args);
}
diff --git a/lib/PublicInbox/Watch.pm b/lib/PublicInbox/Watch.pm
index 6b6be44c..c64689a1 100644
--- a/lib/PublicInbox/Watch.pm
+++ b/lib/PublicInbox/Watch.pm
@@ -46,6 +46,7 @@ sub new {
my ($class, $cfg) = @_;
my (%mdmap, $spamc);
my (%imap, %nntp); # url => [inbox objects] or 'watchspam'
+ my (@imap, @nntp);
# "publicinboxwatch" is the documented namespace
# "publicinboxlearn" is legacy but may be supported
@@ -61,8 +62,10 @@ sub new {
$mdmap{"$dir/cur"} = 'watchspam';
} elsif ($url = imap_url($dir)) {
$imap{$url} = 'watchspam';
+ push @imap, $url;
} elsif ($url = nntp_url($dir)) {
$nntp{$url} = 'watchspam';
+ push @nntp, $url;
} else {
warn "unsupported $k=$dir\n";
}
@@ -92,11 +95,13 @@ sub new {
} elsif ($url = imap_url($watch)) {
return if is_watchspam($url, $imap{$url}, $ibx);
compile_watchheaders($ibx);
- push @{$imap{$url} ||= []}, $ibx;
+ my $n = push @{$imap{$url} ||= []}, $ibx;
+ push @imap, $url if $n == 1;
} elsif ($url = nntp_url($watch)) {
return if is_watchspam($url, $nntp{$url}, $ibx);
compile_watchheaders($ibx);
- push @{$nntp{$url} ||= []}, $ibx;
+ my $n = push @{$nntp{$url} ||= []}, $ibx;
+ push @nntp, $url if $n == 1;
} else {
warn "watch unsupported: $k=$watch\n";
}
@@ -118,6 +123,8 @@ sub new {
pi_cfg => $cfg,
imap => scalar keys %imap ? \%imap : undef,
nntp => scalar keys %nntp? \%nntp : undef,
+ imap_order => scalar(@imap) ? \@imap : undef,
+ nntp_order => scalar(@nntp) ? \@nntp: undef,
importers => {},
opendirs => {}, # dirname => dirhandle (in progress scans)
ops => [], # 'quit', 'full'
@@ -643,7 +650,7 @@ sub nntp_common_init ($) {
my ($self) = @_;
my $cfg = $self->{pi_cfg};
my $nn_args = {}; # scheme://authority => Net::NNTP->new arg
- for my $url (sort keys %{$self->{nntp}}) {
+ for my $url (@{$self->{nntp_order}}) {
my $sec = uri_section(uri_new($url));
# Debug and Timeout are passed to Net::NNTP->new
@@ -755,10 +762,10 @@ sub watch_nntp_init ($$) {
# make sure we can connect and cache the credentials in memory
$self->{nn_arg} = {}; # schema://authority => Net::NNTP->new args
- for my $url (sort keys %{$self->{nntp}}) {
+ for my $url (@{$self->{nntp_order}}) {
nn_for($self, $url, $nn_args);
}
- for my $url (keys %{$self->{nntp}}) {
+ for my $url (@{$self->{nntp_order}}) {
my $uri = uri_new($url);
my $sec = uri_section($uri);
my $intvl = $self->{nntp_opt}->{$sec}->{pollInterval};
^ permalink raw reply related [relevance 7%]
* [PATCH 00/11] lei IMAP read support
@ 2021-02-17 10:06 6% Eric Wong
2021-02-17 10:06 7% ` [PATCH 03/11] watch: connect to NNTP and IMAP in config order Eric Wong
0 siblings, 1 reply; 2+ results
From: Eric Wong @ 2021-02-17 10:06 UTC (permalink / raw)
To: meta
IMAP write support for search results is planned, but testing
could get tricky...
Still unsure about some UI bits w.r.t --format/-f:
https://public-inbox.org/meta/20210217044032.GA17934@dcvr/
convert and import should support parallel network xfers,
NNTP reads, and eventually JMAP...
convert and import don't support compressed mboxes, yet.
Eric Wong (11):
lei: bless config
watch: move imap_common_init to NetReader
watch: connect to NNTP and IMAP in config order
lei import: start rearranging code for IMAP support
lei import: move check_input_format to lei
tests: setup_public_inboxes: use IMAP-friendly newsgroups
t/lei_to_mail: remove unnecessary arg passing
lei convert: mail format conversion sub-command
lei import: add IMAP, (maildir|mbox*):$PATHNAME support
lei: consolidate the bulk of the IPC code
lei: check for IMAP auth errors
MANIFEST | 11 +-
lib/PublicInbox/GitCredential.pm | 18 ++-
lib/PublicInbox/LEI.pm | 62 +++++++-
lib/PublicInbox/LeiAuth.pm | 70 +++++++++
lib/PublicInbox/LeiConvert.pm | 137 +++++++++++++++++
lib/PublicInbox/LeiDedupe.pm | 2 +-
lib/PublicInbox/LeiImport.pm | 156 +++++++++++++-------
lib/PublicInbox/LeiMirror.pm | 19 +--
lib/PublicInbox/LeiOverview.pm | 7 +-
lib/PublicInbox/LeiToMail.pm | 5 +-
lib/PublicInbox/MdirReader.pm | 26 ++++
lib/PublicInbox/NetReader.pm | 242 +++++++++++++++++++++++++++++--
lib/PublicInbox/TestCommon.pm | 15 +-
lib/PublicInbox/Watch.pm | 82 ++---------
t/{home1 => home2}/.gitignore | 0
t/{home1 => home2}/Makefile | 0
t/{home1 => home2}/README | 0
t/lei-convert.t | 36 +++++
t/lei-import-imap.t | 28 ++++
t/lei-import-maildir.t | 4 +-
t/lei_to_mail.t | 14 +-
t/net_reader-imap.t | 40 +++++
xt/lei-auth-fail.t | 20 +++
23 files changed, 820 insertions(+), 174 deletions(-)
create mode 100644 lib/PublicInbox/LeiAuth.pm
create mode 100644 lib/PublicInbox/LeiConvert.pm
rename t/{home1 => home2}/.gitignore (100%)
rename t/{home1 => home2}/Makefile (100%)
rename t/{home1 => home2}/README (100%)
create mode 100644 t/lei-convert.t
create mode 100644 t/lei-import-imap.t
create mode 100644 t/net_reader-imap.t
create mode 100644 xt/lei-auth-fail.t
^ permalink raw reply [relevance 6%]
Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2021-02-17 10:06 6% [PATCH 00/11] lei IMAP read support Eric Wong
2021-02-17 10:06 7% ` [PATCH 03/11] watch: connect to NNTP and IMAP in config order Eric Wong
Code repositories for project(s) associated with this public inbox
https://80x24.org/public-inbox.git
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).