examples/cgit.psgi | 4 ++--
lib/PublicInbox/Cgit.pm | 24 ++++++++++++------------
lib/PublicInbox/Config.pm | 2 +-
lib/PublicInbox/ExtMsg.pm | 8 ++++----
lib/PublicInbox/IMAPD.pm | 28 ++++++++++++++--------------
lib/PublicInbox/Inbox.pm | 10 +++++-----
lib/PublicInbox/InboxIdle.pm | 9 ++++-----
lib/PublicInbox/MDA.pm | 4 ++--
lib/PublicInbox/ManifestJsGz.pm | 2 +-
lib/PublicInbox/NNTP.pm | 22 +++++++++++-----------
lib/PublicInbox/NNTPD.pm | 16 ++++++++--------
lib/PublicInbox/NewsWWW.pm | 15 +++++++--------
lib/PublicInbox/Qspawn.pm | 4 ++--
lib/PublicInbox/Spamcheck.pm | 4 ++--
lib/PublicInbox/Unsubscribe.pm | 6 +++---
lib/PublicInbox/WWW.pm | 27 +++++++++++++--------------
lib/PublicInbox/Watch.pm | 20 ++++++++++----------
lib/PublicInbox/WwwListing.pm | 4 ++--
lib/PublicInbox/WwwStream.pm | 2 +-
lib/PublicInbox/WwwText.pm | 4 ++--
script/public-inbox-learn | 8 ++++----
script/public-inbox-mda | 8 ++++----
scripts/import_slrnspool | 4 ++--
t/imapd.t | 4 ++--
t/inbox_idle.t | 8 ++++----
t/mda_filter_rubylang.t | 4 ++--
t/nntp.t | 2 +-
t/psgi_mount.t | 6 +++---
t/psgi_search.t | 6 +++---
t/psgi_v2.t | 11 +++++------
t/watch_filter_rubylang.t | 10 +++++-----
t/watch_maildir.t | 26 +++++++++++++-------------
t/watch_maildir_v2.t | 48 ++++++++++++++++++++++++------------------------
t/watch_multiple_headers.t | 8 ++++----
diff --git a/examples/cgit.psgi b/examples/cgit.psgi
index 7ad38e2802246fe491ad5464da5964440e4894b9..48e3798b4e1402e4083bc19fd0321381cda9300e 100644
--- a/examples/cgit.psgi
+++ b/examples/cgit.psgi
@@ -14,8 +14,8 @@ use warnings;
use Plack::Builder;
use PublicInbox::Cgit;
use PublicInbox::Config;
-my $pi_config = PublicInbox::Config->new;
-my $cgit = PublicInbox::Cgit->new($pi_config);
+my $pi_cfg = PublicInbox::Config->new;
+my $cgit = PublicInbox::Cgit->new($pi_cfg);
builder {
eval { enable 'ReverseProxy' };
diff --git a/lib/PublicInbox/Cgit.pm b/lib/PublicInbox/Cgit.pm
index fb0d0e60244ab4e1599a3296183ff2de46490094..472509a80852f398ecee8f598c896127d923992d 100644
--- a/lib/PublicInbox/Cgit.pm
+++ b/lib/PublicInbox/Cgit.pm
@@ -16,9 +16,9 @@ use PublicInbox::Qspawn;
use PublicInbox::WwwStatic qw(r);
sub locate_cgit ($) {
- my ($pi_config) = @_;
- my $cgit_bin = $pi_config->{'publicinbox.cgitbin'};
- my $cgit_data = $pi_config->{'publicinbox.cgitdata'};
+ my ($pi_cfg) = @_;
+ my $cgit_bin = $pi_cfg->{'publicinbox.cgitbin'};
+ my $cgit_data = $pi_cfg->{'publicinbox.cgitdata'};
# /var/www/htdocs/cgit is the default install path from cgit.git
# /usr/{lib,share}/cgit is where Debian puts cgit
@@ -51,28 +51,28 @@ ($cgit_bin, $cgit_data);
}
sub new {
- my ($class, $pi_config) = @_;
- my ($cgit_bin, $cgit_data) = locate_cgit($pi_config);
+ my ($class, $pi_cfg) = @_;
+ my ($cgit_bin, $cgit_data) = locate_cgit($pi_cfg);
my $self = bless {
cmd => [ $cgit_bin ],
cgit_data => $cgit_data,
- pi_config => $pi_config,
+ pi_cfg => $pi_cfg,
}, $class;
- $pi_config->fill_all; # fill in -code_repos mapped to inboxes
+ $pi_cfg->fill_all; # fill in -code_repos mapped to inboxes
# some cgit repos may not be mapped to inboxes, so ensure those exist:
- my $code_repos = $pi_config->{-code_repos};
- foreach my $k (keys %$pi_config) {
+ my $code_repos = $pi_cfg->{-code_repos};
+ foreach my $k (keys %$pi_cfg) {
$k =~ /\Acoderepo\.(.+)\.dir\z/ or next;
- my $dir = $pi_config->{$k};
+ my $dir = $pi_cfg->{$k};
$code_repos->{$1} ||= PublicInbox::Git->new($dir);
}
while (my ($nick, $repo) = each %$code_repos) {
$self->{"\0$nick"} = $repo;
}
- my $cgit_static = $pi_config->{-cgit_static};
+ my $cgit_static = $pi_cfg->{-cgit_static};
my $static = join('|', map { quotemeta $_ } keys %$cgit_static);
$self->{static} = qr/\A($static)\z/;
$self;
@@ -120,7 +120,7 @@ $cgi_env->{'HTTPS'} = 'on' if $env->{'psgi.url_scheme'} eq 'https';
my $rdr = input_prepare($env) or return r(500);
my $qsp = PublicInbox::Qspawn->new($self->{cmd}, $cgi_env, $rdr);
- my $limiter = $self->{pi_config}->limiter('-cgit');
+ my $limiter = $self->{pi_cfg}->limiter('-cgit');
$qsp->psgi_return($env, $limiter, $parse_cgi_headers);
}
diff --git a/lib/PublicInbox/Config.pm b/lib/PublicInbox/Config.pm
index 1844f8b24132152becfd2cf695c76c2ae0d98a5f..cafd9c3bafe364eaaeedcb478cc9e23fd1a49dfc 100644
--- a/lib/PublicInbox/Config.pm
+++ b/lib/PublicInbox/Config.pm
@@ -425,7 +425,7 @@ return;
}
$ibx->{name} = $name;
- $ibx->{-pi_config} = $self;
+ $ibx->{-pi_cfg} = $self;
$ibx = PublicInbox::Inbox->new($ibx);
foreach (@{$ibx->{address}}) {
my $lc_addr = lc($_);
diff --git a/lib/PublicInbox/ExtMsg.pm b/lib/PublicInbox/ExtMsg.pm
index 43acfb5377a0c1c537b421d4e85d17623ab25b1c..8da96df699c2bba7c741e0d79bf2739914794ef1 100644
--- a/lib/PublicInbox/ExtMsg.pm
+++ b/lib/PublicInbox/ExtMsg.pm
@@ -105,8 +105,8 @@ }
sub ext_msg_ALL ($) {
my ($ctx) = @_;
- my $ALL = $ctx->{www}->{pi_config}->ALL or return;
- my $by_eidx_key = $ctx->{www}->{pi_config}->{-by_eidx_key};
+ my $ALL = $ctx->{www}->{pi_cfg}->ALL or return;
+ my $by_eidx_key = $ctx->{www}->{pi_cfg}->{-by_eidx_key};
my $cur_key = $ctx->{ibx}->eidx_key;
my %seen = ($cur_key => 1);
my ($id, $prev);
@@ -139,11 +139,11 @@
if ($ctx->{env}->{'pi-httpd.async'}) {
require PublicInbox::ConfigIter;
my $iter = PublicInbox::ConfigIter->new(
- $ctx->{www}->{pi_config},
+ $ctx->{www}->{pi_cfg},
\&ext_msg_step, $ctx);
$iter->event_step;
} else {
- $ctx->{www}->{pi_config}->each_inbox(\&ext_msg_i, $ctx);
+ $ctx->{www}->{pi_cfg}->each_inbox(\&ext_msg_i, $ctx);
finalize_exact($ctx);
}
};
diff --git a/lib/PublicInbox/IMAPD.pm b/lib/PublicInbox/IMAPD.pm
index 4a37734e8e0c9ced429eeb6d772a5c55a67850bb..fb9458477ef7a09d135cc21c6ac8f252985830dd 100644
--- a/lib/PublicInbox/IMAPD.pm
+++ b/lib/PublicInbox/IMAPD.pm
@@ -19,12 +19,12 @@ mailboxes => {},
err => \*STDERR,
out => \*STDOUT,
# accept_tls => { SSL_server => 1, ..., SSL_reuse_ctx => ... }
- # pi_config => PublicInbox::Config
+ # pi_cfg => PublicInbox::Config
# idler => PublicInbox::InboxIdle
}, $class;
}
-sub imapd_refresh_ibx { # pi_config->each_inbox cb
+sub imapd_refresh_ibx { # pi_cfg->each_inbox cb
my ($ibx, $imapd) = @_;
my $ngname = $ibx->{newsgroup} or return;
@@ -60,7 +60,7 @@ } while ($ngname =~ s/\.[^\.]+\z//);
}
sub imapd_refresh_finalize {
- my ($imapd, $pi_config) = @_;
+ my ($imapd, $pi_cfg) = @_;
my $mailboxes;
if (my $next = delete $imapd->{imapd_next}) {
$imapd->{mailboxes} = delete $next->{mailboxes};
@@ -78,40 +78,40 @@ $u =~ s/\Ainbox(\.|\z)/INBOX$1/i;
qq[* LIST (\\Has${no}Children) "." $u\r\n]
} keys %$mailboxes
];
- $imapd->{pi_config} = $pi_config;
+ $imapd->{pi_cfg} = $pi_cfg;
if (my $idler = $imapd->{idler}) {
- $idler->refresh($pi_config);
+ $idler->refresh($pi_cfg);
}
}
-sub imapd_refresh_step { # pi_config->iterate_start cb
- my ($pi_config, $section, $imapd) = @_;
+sub imapd_refresh_step { # pi_cfg->iterate_start cb
+ my ($pi_cfg, $section, $imapd) = @_;
if (defined($section)) {
return if $section !~ m!\Apublicinbox\.([^/]+)\z!;
- my $ibx = $pi_config->lookup_name($1) or return;
+ my $ibx = $pi_cfg->lookup_name($1) or return;
imapd_refresh_ibx($ibx, $imapd->{imapd_next});
} else { # undef == "EOF"
- imapd_refresh_finalize($imapd, $pi_config);
+ imapd_refresh_finalize($imapd, $pi_cfg);
}
}
sub refresh_groups {
my ($self, $sig) = @_;
- my $pi_config = PublicInbox::Config->new;
+ my $pi_cfg = PublicInbox::Config->new;
if ($sig) { # SIGHUP is handled through the event loop
$self->{imapd_next} = { dummies => {}, mailboxes => {} };
- my $iter = PublicInbox::ConfigIter->new($pi_config,
+ my $iter = PublicInbox::ConfigIter->new($pi_cfg,
\&imapd_refresh_step, $self);
$iter->event_step;
} else { # initial start is synchronous
$self->{dummies} = {};
- $pi_config->each_inbox(\&imapd_refresh_ibx, $self);
- imapd_refresh_finalize($self, $pi_config);
+ $pi_cfg->each_inbox(\&imapd_refresh_ibx, $self);
+ imapd_refresh_finalize($self, $pi_cfg);
}
}
sub idler_start {
- $_[0]->{idler} //= PublicInbox::InboxIdle->new($_[0]->{pi_config});
+ $_[0]->{idler} //= PublicInbox::InboxIdle->new($_[0]->{pi_cfg});
}
1;
diff --git a/lib/PublicInbox/Inbox.pm b/lib/PublicInbox/Inbox.pm
index 52aece7c9db73b7efd10c61e57c838ddc36821b0..586bd56110e5e548f3ea9c01bdf52e45915b5397 100644
--- a/lib/PublicInbox/Inbox.pm
+++ b/lib/PublicInbox/Inbox.pm
@@ -85,7 +85,7 @@ $opts->{$field} = $val || $default;
}
sub _set_limiter ($$$) {
- my ($self, $pi_config, $pfx) = @_;
+ my ($self, $pi_cfg, $pfx) = @_;
my $lkey = "-${pfx}_limiter";
$self->{$lkey} ||= do {
# full key is: publicinbox.$NAME.httpbackendmax
@@ -96,7 +96,7 @@ if ($val =~ /\A[0-9]+\z/) {
require PublicInbox::Qspawn;
$lim = PublicInbox::Qspawn::Limiter->new($val);
} elsif ($val =~ /\A[a-z][a-z0-9]*\z/) {
- $lim = $pi_config->limiter($val);
+ $lim = $pi_cfg->limiter($val);
warn "$mkey limiter=$val not found\n" if !$lim;
} else {
warn "$mkey limiter=$val not understood\n";
@@ -110,10 +110,10 @@ my ($class, $opts) = @_;
my $v = $opts->{address} ||= [ 'public-inbox@example.com' ];
my $p = $opts->{-primary_address} = ref($v) eq 'ARRAY' ? $v->[0] : $v;
$opts->{domain} = ($p =~ /\@(\S+)\z/) ? $1 : 'localhost';
- my $pi_config = delete $opts->{-pi_config};
- _set_limiter($opts, $pi_config, 'httpbackend');
+ my $pi_cfg = delete $opts->{-pi_cfg};
+ _set_limiter($opts, $pi_cfg, 'httpbackend');
_set_uint($opts, 'feedmax', 25);
- $opts->{nntpserver} ||= $pi_config->{'publicinbox.nntpserver'};
+ $opts->{nntpserver} ||= $pi_cfg->{'publicinbox.nntpserver'};
my $dir = $opts->{inboxdir};
if (defined $dir && -f "$dir/inbox.lock") {
$opts->{version} = 2;
diff --git a/lib/PublicInbox/InboxIdle.pm b/lib/PublicInbox/InboxIdle.pm
index 0cdd2e2a8e56df7a54103d5a6592c6dea06822bb..2737bbbd01fbde2583de42f97f3383098a428999 100644
--- a/lib/PublicInbox/InboxIdle.pm
+++ b/lib/PublicInbox/InboxIdle.pm
@@ -2,7 +2,6 @@ # Copyright (C) 2020 all contributors
# License: AGPL-3.0+
# fields:
-# pi_config: PublicInbox::Config ref
# inot: Linux::Inotify2-like object
# pathmap => { inboxdir => [ ibx, watch1, watch2, watch3... ] } mapping
package PublicInbox::InboxIdle;
@@ -51,12 +50,12 @@ # TODO: detect deleted packs (and possibly other files)
}
sub refresh {
- my ($self, $pi_config) = @_;
- $pi_config->each_inbox(\&in2_arm, $self);
+ my ($self, $pi_cfg) = @_;
+ $pi_cfg->each_inbox(\&in2_arm, $self);
}
sub new {
- my ($class, $pi_config) = @_;
+ my ($class, $pi_cfg) = @_;
my $self = bless {}, $class;
my $inot;
if ($ino_cls) {
@@ -70,7 +69,7 @@ }
$self->{inot} = $inot;
$self->{pathmap} = {}; # inboxdir => [ ibx, watch1, watch2, watch3...]
$self->{on_unlock} = {}; # lock path => ibx
- refresh($self, $pi_config);
+ refresh($self, $pi_cfg);
PublicInbox::FakeInotify::poll_once($self) if !$ino_cls;
$self;
}
diff --git a/lib/PublicInbox/MDA.pm b/lib/PublicInbox/MDA.pm
index fa4a2ad85929a01b3f680e7b4ca278654b98b8f0..0377a87771a800550eadae875606c9a6fc06d9ef 100644
--- a/lib/PublicInbox/MDA.pm
+++ b/lib/PublicInbox/MDA.pm
@@ -83,7 +83,7 @@ }
}
sub inboxes_for_list_id ($$) {
- my ($klass, $config, $simple) = @_;
+ my ($klass, $pi_cfg, $simple) = @_;
# newer Email::Simple allows header_raw, as does Email::MIME:
my @list_ids = $simple->can('header_raw') ?
@@ -92,7 +92,7 @@ $simple->header('List-Id');
my @dests;
for my $list_id (@list_ids) {
$list_id =~ /<[ \t]*(.+)?[ \t]*>/ or next;
- if (my $ibx = $config->lookup_list_id($1)) {
+ if (my $ibx = $pi_cfg->lookup_list_id($1)) {
push @dests, $ibx;
}
}
diff --git a/lib/PublicInbox/ManifestJsGz.pm b/lib/PublicInbox/ManifestJsGz.pm
index 2c4a231d9164157bb88a008bd6a02ddea3727710..fb7a45e733d084d6e47eeec056ffca6068c43f03 100644
--- a/lib/PublicInbox/ManifestJsGz.pm
+++ b/lib/PublicInbox/ManifestJsGz.pm
@@ -71,7 +71,7 @@ }
sub ibx_entry {
my ($ctx, $ibx) = @_;
- my $ALL = $ctx->{www}->{pi_config}->ALL;
+ my $ALL = $ctx->{www}->{pi_cfg}->ALL;
if ($ALL) {
eidx_manifest_add($ctx, $ALL, $ibx);
} else {
diff --git a/lib/PublicInbox/NNTP.pm b/lib/PublicInbox/NNTP.pm
index 766ea89eec4cae031cf81720289f8f0787510fe2..0b43cdbc5b9308378d953b250e45f3e8da398ea6 100644
--- a/lib/PublicInbox/NNTP.pm
+++ b/lib/PublicInbox/NNTP.pm
@@ -129,7 +129,7 @@ sub list_active_i { # "LIST ACTIVE" and also just "LIST" (no args)
my ($self, $groupnames) = @_;
my @window = splice(@$groupnames, 0, 100) or return 0;
my $ibx;
- my $groups = $self->{nntpd}->{pi_config}->{-by_newsgroup};
+ my $groups = $self->{nntpd}->{pi_cfg}->{-by_newsgroup};
for my $ngname (@window) {
$ibx = $groups->{$ngname} and group_line($self, $ibx);
}
@@ -146,7 +146,7 @@
sub list_active_times_i {
my ($self, $groupnames) = @_;
my @window = splice(@$groupnames, 0, 100) or return 0;
- my $groups = $self->{nntpd}->{pi_config}->{-by_newsgroup};
+ my $groups = $self->{nntpd}->{pi_cfg}->{-by_newsgroup};
for my $ngname (@window) {
my $ibx = $groups->{$ngname} or next;
my $c = eval { $ibx->uidvalidity } // time;
@@ -165,7 +165,7 @@
sub list_newsgroups_i {
my ($self, $groupnames) = @_;
my @window = splice(@$groupnames, 0, 100) or return 0;
- my $groups = $self->{nntpd}->{pi_config}->{-by_newsgroup};
+ my $groups = $self->{nntpd}->{pi_cfg}->{-by_newsgroup};
my $ibx;
for my $ngname (@window) {
$ibx = $groups->{$ngname} and
@@ -268,7 +268,7 @@
sub newgroups_i {
my ($self, $ts, $i, $groupnames) = @_;
my $end = $$i + 100;
- my $groups = $self->{nntpd}->{pi_config}->{-by_newsgroup};
+ my $groups = $self->{nntpd}->{pi_cfg}->{-by_newsgroup};
while ($$i < $end) {
my $ngname = $groupnames->[$$i++] // return;
my $ibx = $groups->{$ngname} or next; # expired on reload
@@ -323,7 +323,7 @@
sub newnews_i {
my ($self, $names, $ts, $prev) = @_;
my $ngname = $names->[0];
- if (my $ibx = $self->{nntpd}->{pi_config}->{-by_newsgroup}->{$ngname}) {
+ if (my $ibx = $self->{nntpd}->{pi_cfg}->{-by_newsgroup}->{$ngname}) {
if (my $over = $ibx->over) {
my $msgs = $over->query_ts($ts, $$prev);
if (scalar @$msgs) {
@@ -362,7 +362,7 @@
sub cmd_group ($$) {
my ($self, $group) = @_;
my $nntpd = $self->{nntpd};
- my $ibx = $nntpd->{pi_config}->{-by_newsgroup}->{$group} or
+ my $ibx = $nntpd->{pi_cfg}->{-by_newsgroup}->{$group} or
return '411 no such news group';
$nntpd->idler_start;
@@ -439,13 +439,13 @@ my ($self, $cur_ibx, $smsg) = @_;
my $nntpd = $self->{nntpd};
my $cur_ng = $cur_ibx->{newsgroup};
my $xref;
- if (my $ALL = $nntpd->{pi_config}->ALL) {
+ if (my $ALL = $nntpd->{pi_cfg}->ALL) {
$xref = $ALL->nntp_xref_for($cur_ibx, $smsg);
- xref_by_tc($xref, $nntpd->{pi_config}, $smsg);
+ xref_by_tc($xref, $nntpd->{pi_cfg}, $smsg);
} else { # slow path
$xref = { $cur_ng => $smsg->{num} };
my $mid = $smsg->{mid};
- for my $ibx (values %{$nntpd->{pi_config}->{-by_newsgroup}}) {
+ for my $ibx (values %{$nntpd->{pi_cfg}->{-by_newsgroup}}) {
next if defined($xref->{$ibx->{newsgroup}});
my $num = eval { $ibx->mm->num_for($mid) } // next;
$xref->{$ibx->{newsgroup}} = $num;
@@ -733,7 +733,7 @@ if ($cur_ibx) {
my $n = $cur_ibx->mm->num_for($mid);
return ($cur_ibx, $n) if defined $n;
}
- my $pi_cfg = $self->{nntpd}->{pi_config};
+ my $pi_cfg = $self->{nntpd}->{pi_cfg};
if (my $ALL = $pi_cfg->ALL) {
my ($id, $prev);
while (my $smsg = $ALL->over->next_by_mid($mid, \$id, \$prev)) {
@@ -1014,7 +1014,7 @@ my ($self, $mid) = @_;
return r501 unless $mid =~ $ONE_MSGID;
$mid = $1;
my @paths;
- my $pi_cfg = $self->{nntpd}->{pi_config};
+ my $pi_cfg = $self->{nntpd}->{pi_cfg};
my $groups = $pi_cfg->{-by_newsgroup};
if (my $ALL = $pi_cfg->ALL) {
my ($id, $prev, %seen);
diff --git a/lib/PublicInbox/NNTPD.pm b/lib/PublicInbox/NNTPD.pm
index 03c56db30727ec2dbee9e205592bd459f78ef892..953228d0287823ea691e461fb5fae5b86f8c6e99 100644
--- a/lib/PublicInbox/NNTPD.pm
+++ b/lib/PublicInbox/NNTPD.pm
@@ -12,8 +12,8 @@ use PublicInbox::InboxIdle;
sub new {
my ($class) = @_;
- my $pi_config = PublicInbox::Config->new;
- my $name = $pi_config->{'publicinbox.nntpserver'};
+ my $pi_cfg = PublicInbox::Config->new;
+ my $name = $pi_cfg->{'publicinbox.nntpserver'};
if (!defined($name) or $name eq '') {
$name = hostname;
} elsif (ref($name) eq 'ARRAY') {
@@ -24,7 +24,7 @@ bless {
groups => {},
err => \*STDERR,
out => \*STDOUT,
- pi_config => $pi_config,
+ pi_cfg => $pi_cfg,
servername => $name,
greet => \"201 $name ready - post via email\r\n",
# accept_tls => { SSL_server => 1, ..., SSL_reuse_ctx => ... }
@@ -34,9 +34,9 @@ }
sub refresh_groups {
my ($self, $sig) = @_;
- my $pi_config = $sig ? PublicInbox::Config->new : $self->{pi_config};
- my $groups = $pi_config->{-by_newsgroup}; # filled during each_inbox
- $pi_config->each_inbox(sub {
+ my $pi_cfg = $sig ? PublicInbox::Config->new : $self->{pi_cfg};
+ my $groups = $pi_cfg->{-by_newsgroup}; # filled during each_inbox
+ $pi_cfg->each_inbox(sub {
my ($ibx) = @_;
my $ngname = $ibx->{newsgroup};
if (defined($ngname) && $ibx->nntp_usable) {
@@ -54,11 +54,11 @@ }
});
$self->{groupnames} = [ sort(keys %$groups) ];
# this will destroy old groups that got deleted
- $self->{pi_config} = $pi_config;
+ $self->{pi_cfg} = $pi_cfg;
}
sub idler_start {
- $_[0]->{idler} //= PublicInbox::InboxIdle->new($_[0]->{pi_config});
+ $_[0]->{idler} //= PublicInbox::InboxIdle->new($_[0]->{pi_cfg});
}
1;
diff --git a/lib/PublicInbox/NewsWWW.pm b/lib/PublicInbox/NewsWWW.pm
index ade8dfd175f402af2bebcaf7fb446f850a783e30..61d9ae7cacecbbc4facaeb05d119acdfaf433e95 100644
--- a/lib/PublicInbox/NewsWWW.pm
+++ b/lib/PublicInbox/NewsWWW.pm
@@ -13,9 +13,8 @@ use PublicInbox::MID qw(mid_escape);
use PublicInbox::Hval qw(prurl);
sub new {
- my ($class, $pi_config) = @_;
- $pi_config ||= PublicInbox::Config->new;
- bless { pi_config => $pi_config }, $class;
+ my ($class, $pi_cfg) = @_;
+ bless { pi_cfg => $pi_cfg // PublicInbox::Config->new }, $class;
}
sub redirect ($$) {
@@ -47,8 +46,8 @@ # some links may have the article number in them:
# /inbox.foo.bar/123456
my (undef, @parts) = split(m!/!, $env->{PATH_INFO});
my ($ng, $article) = @parts;
- my $pi_config = $self->{pi_config};
- if (my $ibx = $pi_config->lookup_newsgroup($ng)) {
+ my $pi_cfg = $self->{pi_cfg};
+ if (my $ibx = $pi_cfg->lookup_newsgroup($ng)) {
my $url = prurl($env, $ibx->{url});
my $code = 301;
if (defined $article && $article =~ /\A[0-9]+\z/) {
@@ -71,9 +70,9 @@ if ($parts[-1] eq '') {
pop @parts;
push @try, join('/', @parts);
}
- my $ALL = $pi_config->ALL;
+ my $ALL = $pi_cfg->ALL;
if (my $over = $ALL ? $ALL->over : undef) {
- my $by_eidx_key = $pi_config->{-by_eidx_key};
+ my $by_eidx_key = $pi_cfg->{-by_eidx_key};
for my $mid (@try) {
my ($id, $prev);
while (my $x = $over->next_by_mid($mid, \$id, \$prev)) {
@@ -90,7 +89,7 @@ }
} else { # slow path, scan every inbox
for my $mid (@try) {
my $arg = [ $mid ]; # [1] => result
- $pi_config->each_inbox(\&try_inbox, $arg);
+ $pi_cfg->each_inbox(\&try_inbox, $arg);
return $arg->[1] if $arg->[1];
}
}
diff --git a/lib/PublicInbox/Qspawn.pm b/lib/PublicInbox/Qspawn.pm
index 88b6d390a0721e529f31f9826144dad641aa067c..2aa2042ab7e870fbdf499dcb0e3f1495138e6702 100644
--- a/lib/PublicInbox/Qspawn.pm
+++ b/lib/PublicInbox/Qspawn.pm
@@ -359,12 +359,12 @@ }, $class;
}
sub setup_rlimit {
- my ($self, $name, $config) = @_;
+ my ($self, $name, $cfg) = @_;
foreach my $rlim (@PublicInbox::Spawn::RLIMITS) {
my $k = lc($rlim);
$k =~ tr/_//d;
$k = "publicinboxlimiter.$name.$k";
- defined(my $v = $config->{$k}) or next;
+ defined(my $v = $cfg->{$k}) or next;
my @rlimit = split(/\s*,\s*/, $v);
if (scalar(@rlimit) == 1) {
push @rlimit, $rlimit[0];
diff --git a/lib/PublicInbox/Spamcheck.pm b/lib/PublicInbox/Spamcheck.pm
index ffebb3cf923fda19f322cdc76e7253fc41b76130..218fcc013349b86cd88cd0db287c55b920ee2c26 100644
--- a/lib/PublicInbox/Spamcheck.pm
+++ b/lib/PublicInbox/Spamcheck.pm
@@ -7,8 +7,8 @@ use strict;
use warnings;
sub get {
- my ($config, $key, $default) = @_;
- my $spamcheck = $config->{$key};
+ my ($cfg, $key, $default) = @_;
+ my $spamcheck = $cfg->{$key};
$spamcheck = $default unless $spamcheck;
return if !$spamcheck || $spamcheck eq 'none';
diff --git a/lib/PublicInbox/Unsubscribe.pm b/lib/PublicInbox/Unsubscribe.pm
index 945e7ae77d4c14bdaccfed19363375ad128e4214..b0d3220c3b51f6b80ee80dcffedc401ac282510c 100644
--- a/lib/PublicInbox/Unsubscribe.pm
+++ b/lib/PublicInbox/Unsubscribe.pm
@@ -39,7 +39,7 @@ my $unsubscribe = $opt{unsubscribe} or
die "`unsubscribe' callback not given\n";
bless {
- pi_config => $opt{pi_config}, # PublicInbox::Config
+ pi_cfg => $opt{pi_config}, # PublicInbox::Config
owner_email => $opt{owner_email},
cipher => $cipher,
unsubscribe => $unsubscribe,
@@ -149,9 +149,9 @@ my ($self, $env, $list_addr) = @_;
my $archive_url = $self->{archive_urls}->{$list_addr};
unless ($archive_url) {
- if (my $config = $self->{pi_config}) {
+ if (my $cfg = $self->{pi_cfg}) {
# PublicInbox::Config::lookup
- my $ibx = $config->lookup($list_addr);
+ my $ibx = $cfg->lookup($list_addr);
# PublicInbox::Inbox::base_url
$archive_url = $ibx->base_url if $ibx;
}
diff --git a/lib/PublicInbox/WWW.pm b/lib/PublicInbox/WWW.pm
index 6bae2190ac5f3f4d0e040fb787cc951e2402c87d..a33d25abd44e314b489549a7ea08bb9ad7f4365e 100644
--- a/lib/PublicInbox/WWW.pm
+++ b/lib/PublicInbox/WWW.pm
@@ -32,9 +32,8 @@ our $ATTACH_RE = qr!([0-9][0-9\.]*)-($PublicInbox::Hval::FN)!;
our $OID_RE = qr![a-f0-9]{7,}!;
sub new {
- my ($class, $pi_config) = @_;
- $pi_config ||= PublicInbox::Config->new;
- bless { pi_config => $pi_config }, $class;
+ my ($class, $pi_cfg) = @_;
+ bless { pi_cfg => $pi_cfg // PublicInbox::Config->new }, $class;
}
# backwards compatibility, do not use
@@ -169,14 +168,14 @@ for (qw(SearchView MboxGz WwwAltId)) {
eval "require PublicInbox::$_;";
}
if (ref($self)) {
- my $pi_config = $self->{pi_config};
- if (defined($pi_config->{'publicinbox.cgitrc'})) {
- $pi_config->limiter('-cgit');
+ my $pi_cfg = $self->{pi_cfg};
+ if (defined($pi_cfg->{'publicinbox.cgitrc'})) {
+ $pi_cfg->limiter('-cgit');
}
$self->cgit;
$self->stylesheets_prepare($_) for ('', '../', '../../');
$self->news_www;
- $pi_config->each_inbox(\&preload_inbox);
+ $pi_cfg->each_inbox(\&preload_inbox);
}
}
@@ -210,8 +209,8 @@
# returns undef if valid, array ref response if invalid
sub invalid_inbox ($$) {
my ($ctx, $inbox) = @_;
- my $ibx = $ctx->{www}->{pi_config}->lookup_name($inbox) //
- $ctx->{www}->{pi_config}->lookup_ei($inbox);
+ my $ibx = $ctx->{www}->{pi_cfg}->lookup_name($inbox) //
+ $ctx->{www}->{pi_cfg}->lookup_ei($inbox);
if (defined $ibx) {
$ctx->{ibx} = $ibx;
return;
@@ -481,18 +480,18 @@ sub news_www {
my ($self) = @_;
$self->{news_www} ||= do {
require PublicInbox::NewsWWW;
- PublicInbox::NewsWWW->new($self->{pi_config});
+ PublicInbox::NewsWWW->new($self->{pi_cfg});
}
}
sub cgit {
my ($self) = @_;
$self->{cgit} ||= do {
- my $pi_config = $self->{pi_config};
+ my $pi_cfg = $self->{pi_cfg};
- if (defined($pi_config->{'publicinbox.cgitrc'})) {
+ if (defined($pi_cfg->{'publicinbox.cgitrc'})) {
require PublicInbox::Cgit;
- PublicInbox::Cgit->new($pi_config);
+ PublicInbox::Cgit->new($pi_cfg);
} else {
require Plack::Util;
Plack::Util::inline_object(call => sub { r404() });
@@ -538,7 +537,7 @@ sub { CSS::Minifier::XS::minify($_[0]) };
} || sub { $_[0] };
my $css_map = {};
- my $stylesheets = $self->{pi_config}->{css} || [];
+ my $stylesheets = $self->{pi_cfg}->{css} || [];
my $links = [];
my $inline_ok = 1;
diff --git a/lib/PublicInbox/Watch.pm b/lib/PublicInbox/Watch.pm
index 8bbce92992aa004e26271394bb0c75cffa31fb5d..e1246096dc7b70fd0e1fadfa3e93ccc4df7a7bfc 100644
--- a/lib/PublicInbox/Watch.pm
+++ b/lib/PublicInbox/Watch.pm
@@ -41,7 +41,7 @@ $ibx->{-watchheaders} = $watch_hdrs if scalar @$watch_hdrs;
}
sub new {
- my ($class, $config) = @_;
+ my ($class, $cfg) = @_;
my (%mdmap, $spamc);
my (%imap, %nntp); # url => [inbox objects] or 'watchspam'
@@ -50,7 +50,7 @@ # "publicinboxlearn" is legacy but may be supported
# indefinitely...
foreach my $pfx (qw(publicinboxwatch publicinboxlearn)) {
my $k = "$pfx.watchspam";
- defined(my $dirs = $config->{$k}) or next;
+ defined(my $dirs = $cfg->{$k}) or next;
$dirs = PublicInbox::Config::_array($dirs);
for my $dir (@$dirs) {
my $url;
@@ -69,10 +69,10 @@ }
my $k = 'publicinboxwatch.spamcheck';
my $default = undef;
- my $spamcheck = PublicInbox::Spamcheck::get($config, $k, $default);
+ my $spamcheck = PublicInbox::Spamcheck::get($cfg, $k, $default);
$spamcheck = _spamcheck_cb($spamcheck) if $spamcheck;
- $config->each_inbox(sub {
+ $cfg->each_inbox(sub {
# need to make all inboxes writable for spam removal:
my $ibx = $_[0] = PublicInbox::InboxWritable->new($_[0]);
@@ -113,7 +113,7 @@ max_batch => 10, # avoid hogging locks for too long
spamcheck => $spamcheck,
mdmap => \%mdmap,
mdre => $mdre,
- config => $config,
+ pi_cfg => $cfg,
imap => scalar keys %imap ? \%imap : undef,
nntp => scalar keys %nntp? \%nntp : undef,
importers => {},
@@ -175,7 +175,7 @@ # path must be marked as (S)een
$path =~ /:2,[A-R]*S[T-Za-z]*\z/ or return;
my $eml = eml_from_path($path) or return;
local $SIG{__WARN__} = warn_ignore_cb();
- $self->{config}->each_inbox(\&remove_eml_i, $self, $eml, $path);
+ $self->{pi_cfg}->each_inbox(\&remove_eml_i, $self, $eml, $path);
}
sub import_eml ($$$) {
@@ -316,7 +316,7 @@
# flesh out common IMAP-specific data structures
sub imap_common_init ($) {
my ($self) = @_;
- my $cfg = $self->{config};
+ my $cfg = $self->{pi_cfg};
my $mic_args = {}; # scheme://authority => Mail:IMAPClient arg
for my $url (sort keys %{$self->{imap}}) {
my $uri = PublicInbox::URIimap->new($url);
@@ -418,7 +418,7 @@ # we don't remove unseen messages
if ($flags =~ /\\Seen\b/) {
local $SIG{__WARN__} = warn_ignore_cb();
my $eml = PublicInbox::Eml->new($raw);
- $self->{config}->each_inbox(\&remove_eml_i,
+ $self->{pi_cfg}->each_inbox(\&remove_eml_i,
$self, $eml, "$url UID:$uid");
}
} else {
@@ -775,7 +775,7 @@
# flesh out common NNTP-specific data structures
sub nntp_common_init ($) {
my ($self) = @_;
- my $cfg = $self->{config};
+ my $cfg = $self->{pi_cfg};
my $nn_args = {}; # scheme://authority => Net::NNTP->new arg
for my $url (sort keys %{$self->{nntp}}) {
my $sec = uri_section(uri_new($url));
@@ -966,7 +966,7 @@ import_eml($self, $ibx, $eml);
}
} elsif ($inboxes eq 'watchspam') {
my $eml = PublicInbox::Eml->new(\$raw);
- $self->{config}->each_inbox(\&remove_eml_i,
+ $self->{pi_cfg}->each_inbox(\&remove_eml_i,
$self, $eml, "$url ARTICLE $art");
} else {
die "BUG: destination unknown $inboxes";
diff --git a/lib/PublicInbox/WwwListing.pm b/lib/PublicInbox/WwwListing.pm
index bda2761c63d93091b4680065757a3b241a6eb895..fce0e530b24feb91393951cf24223c99ffb4c115 100644
--- a/lib/PublicInbox/WwwListing.pm
+++ b/lib/PublicInbox/WwwListing.pm
@@ -44,7 +44,7 @@ sub url_regexp {
my ($ctx, $key, $default) = @_;
$key //= 'publicInbox.wwwListing';
$default //= '404';
- my $v = $ctx->{www}->{pi_config}->{lc $key} // $default;
+ my $v = $ctx->{www}->{pi_cfg}->{lc $key} // $default;
again:
if ($v eq 'match=domain') {
my $h = $ctx->{env}->{HTTP_HOST} // $ctx->{env}->{SERVER_NAME};
@@ -70,7 +70,7 @@ sub response {
my ($class, $ctx) = @_;
bless $ctx, $class;
my $re = $ctx->url_regexp or return $ctx->psgi_triple;
- my $iter = PublicInbox::ConfigIter->new($ctx->{www}->{pi_config},
+ my $iter = PublicInbox::ConfigIter->new($ctx->{www}->{pi_cfg},
\&list_match_i, $re, $ctx);
sub {
$ctx->{-wcb} = $_[0]; # HTTP server callback
diff --git a/lib/PublicInbox/WwwStream.pm b/lib/PublicInbox/WwwStream.pm
index 849831a6f8e26b4f11b9480046d4a62c59fefddf..34e124358d5e588cfae0f8f9cbfb730e33ee921c 100644
--- a/lib/PublicInbox/WwwStream.pm
+++ b/lib/PublicInbox/WwwStream.pm
@@ -81,7 +81,7 @@ my ($ctx) = @_;
my $ibx = $ctx->{ibx};
my @ret;
if (defined(my $cr = $ibx->{coderepo})) {
- my $cfg = $ctx->{www}->{pi_config};
+ my $cfg = $ctx->{www}->{pi_cfg};
my $env = $ctx->{env};
for my $cr_name (@$cr) {
my $urls = $cfg->{"coderepo.$cr_name.cgiturl"};
diff --git a/lib/PublicInbox/WwwText.pm b/lib/PublicInbox/WwwText.pm
index 53e15e454629e78acd49d160773e1a607ce0bcc6..a85609168d23a318fe373c4712a153901408c18c 100644
--- a/lib/PublicInbox/WwwText.pm
+++ b/lib/PublicInbox/WwwText.pm
@@ -189,9 +189,9 @@ ; the inbox is indexed with Xapian. `@@ @@'
; line number ranges in `[PATCH]' emails link to /$INBOX_NAME/$OID/s/,
; an HTTP endpoint which reconstructs git blobs via git-apply(1).
EOF
- my $pi_config = $ctx->{www}->{pi_config};
+ my $pi_cfg = $ctx->{www}->{pi_cfg};
for my $cr_name (@$cr) {
- my $urls = $pi_config->{"coderepo.$cr_name.cgiturl"};
+ my $urls = $pi_cfg->{"coderepo.$cr_name.cgiturl"};
my $path = "/path/to/$cr_name";
$cr_name = dq_escape($cr_name);
diff --git a/script/public-inbox-learn b/script/public-inbox-learn
index fb2d86ec141ff11741d6681975d9a0feb7579c44..9352c8ff7dd41088796eb60607452cea3b98cc0d 100755
--- a/script/public-inbox-learn
+++ b/script/public-inbox-learn
@@ -36,7 +36,7 @@ }
die "--all only works with `rm'\n" if $opt{all} && $train ne 'rm';
my $spamc = PublicInbox::Spamcheck::Spamc->new;
-my $pi_config = PublicInbox::Config->new;
+my $pi_cfg = PublicInbox::Config->new;
my $err;
my $mime = PublicInbox::Eml->new(do{
local $/;
@@ -87,7 +87,7 @@ }
# spam is removed from all known inboxes since it is often Bcc:-ed
if ($train eq 'spam' || ($train eq 'rm' && $opt{all})) {
- $pi_config->each_inbox(sub {
+ $pi_cfg->each_inbox(sub {
my ($ibx) = @_;
$ibx = PublicInbox::InboxWritable->new($ibx);
my $im = $ibx->importer(0);
@@ -102,7 +102,7 @@ my %dests; # address =>
for ($mime->header('Cc'), $mime->header('To')) {
foreach my $addr (PublicInbox::Address::emails($_)) {
$addr = lc($addr);
- $dests{$addr} //= $pi_config->lookup($addr) // 0;
+ $dests{$addr} //= $pi_cfg->lookup($addr) // 0;
}
}
@@ -113,7 +113,7 @@ next unless ref($ibx); # $ibx may be 0
next if $seen{"$ibx"}++;
remove_or_add($ibx, $train, $mime, $addr);
}
- my $dests = PublicInbox::MDA->inboxes_for_list_id($pi_config, $mime);
+ my $dests = PublicInbox::MDA->inboxes_for_list_id($pi_cfg, $mime);
for my $ibx (@$dests) {
next if $seen{"$ibx"}++;
remove_or_add($ibx, $train, $mime, $ibx->{-primary_address});
diff --git a/script/public-inbox-mda b/script/public-inbox-mda
index 3ed5abb6d910dfb76b586a5fbd4dfb4ca9dfa024..40963f8e1acf5d814352f81cbe5b916afa67d3da 100755
--- a/script/public-inbox-mda
+++ b/script/public-inbox-mda
@@ -42,18 +42,18 @@ my $str = do { local $/; };
$str =~ s/\A[\r\n]*From [^\r\n]*\r?\n//s;
$ems->prepare(\$str);
my $eml = PublicInbox::Eml->new(\$str);
-my $config = PublicInbox::Config->new;
+my $cfg = PublicInbox::Config->new;
my $key = 'publicinboxmda.spamcheck';
my $default = 'PublicInbox::Spamcheck::Spamc';
-my $spamc = PublicInbox::Spamcheck::get($config, $key, $default);
+my $spamc = PublicInbox::Spamcheck::get($cfg, $key, $default);
my $dests = [];
my $recipient = $ENV{ORIGINAL_RECIPIENT};
if (defined $recipient) {
- my $ibx = $config->lookup($recipient); # first check
+ my $ibx = $cfg->lookup($recipient); # first check
push @$dests, $ibx if $ibx;
}
if (!scalar(@$dests)) {
- $dests = PublicInbox::MDA->inboxes_for_list_id($config, $eml);
+ $dests = PublicInbox::MDA->inboxes_for_list_id($cfg, $eml);
if (!scalar(@$dests) && !defined($recipient)) {
die "ORIGINAL_RECIPIENT not defined in ENV\n";
}
diff --git a/scripts/import_slrnspool b/scripts/import_slrnspool
index bdcc605c245434bc5ca6c47524d09ce6aef45147..0acffc1f84f0e7780fab334a12244dd95a6c3628 100755
--- a/scripts/import_slrnspool
+++ b/scripts/import_slrnspool
@@ -22,8 +22,8 @@ $SIG{TERM} = $sighandler;
my $spool = shift @ARGV or die usage();
my $recipient = $ENV{ORIGINAL_RECIPIENT};
defined $recipient or die usage();
-my $config = PublicInbox::Config->new;
-my $ibx = $config->lookup($recipient);
+my $cfg = PublicInbox::Config->new;
+my $ibx = $cfg->lookup($recipient);
my $git = $ibx->git;
my $im;
if ($ibx->version == 2) {
diff --git a/t/imapd.t b/t/imapd.t
index c1c52839f2c1cacec57b949541c4a7c67024d739..43ec200cd25d6c54fc85da364b6d1f738affa011 100644
--- a/t/imapd.t
+++ b/t/imapd.t
@@ -251,8 +251,8 @@ ok($mic->logout, 'logout works');
my $have_inotify = eval { require Linux::Inotify2; 1 };
-my $pi_config = PublicInbox::Config->new;
-$pi_config->each_inbox(sub {
+my $pi_cfg = PublicInbox::Config->new;
+$pi_cfg->each_inbox(sub {
my ($ibx) = @_;
my $env = { ORIGINAL_RECIPIENT => $ibx->{-primary_address} };
my $name = $ibx->{name};
diff --git a/t/inbox_idle.t b/t/inbox_idle.t
index e16ee11b18970deaad33015173f84af101d0ab6d..198856bdd19b3291f1b426814fe26c2e3ef98be4 100644
--- a/t/inbox_idle.t
+++ b/t/inbox_idle.t
@@ -32,14 +32,14 @@ $sidx->idx_acquire;
$sidx->set_metadata_once;
$sidx->idx_release; # allow watching on lockfile
}
- my $pi_config = PublicInbox::Config->new(\<new(\<each_inbox(sub { shift->subscribe_unlock($ident, $obj) });
- my $ii = PublicInbox::InboxIdle->new($pi_config);
+ $pi_cfg->each_inbox(sub { shift->subscribe_unlock($ident, $obj) });
+ my $ii = PublicInbox::InboxIdle->new($pi_cfg);
ok($ii, 'InboxIdle created');
SKIP: {
skip('inotify or kqueue missing', 1) unless $ii->{sock};
@@ -50,7 +50,7 @@ $im->done;
PublicInbox::SearchIdx->new($ibx)->index_sync if $V == 1;
$ii->event_step;
is(scalar @{$obj->{called}}, 1, 'called on unlock');
- $pi_config->each_inbox(sub { shift->unsubscribe_unlock($ident) });
+ $pi_cfg->each_inbox(sub { shift->unsubscribe_unlock($ident) });
ok($im->add(eml_load('t/data/0001.patch')), "$V added #2");
$im->done;
PublicInbox::SearchIdx->new($ibx)->index_sync if $V == 1;
diff --git a/t/mda_filter_rubylang.t b/t/mda_filter_rubylang.t
index 754d52f75cdf0331776dd87bcd6de7807f7df14a..489ea223b2b02c0ece9299bfd4f02427f0dce690 100644
--- a/t/mda_filter_rubylang.t
+++ b/t/mda_filter_rubylang.t
@@ -44,8 +44,8 @@ something
EOF
ok(run_script(['-mda'], $env, $opt), 'message delivered');
}
- my $config = PublicInbox::Config->new;
- my $ibx = $config->lookup_name($v);
+ my $cfg = PublicInbox::Config->new;
+ my $ibx = $cfg->lookup_name($v);
# make sure all serials are searchable:
for my $i (1..2) {
diff --git a/t/nntp.t b/t/nntp.t
index 3d2f524c4a7d4c704a0ee269256bfef8cd81dc52..b745886d062594f65613689027b24f2829478006 100644
--- a/t/nntp.t
+++ b/t/nntp.t
@@ -113,7 +113,7 @@ my $hdr = $mime->header_obj;
my $mock_self = {
nntpd => {
servername => 'example.com',
- pi_config => bless {}, 'PublicInbox::Config',
+ pi_cfg => bless {}, 'PublicInbox::Config',
},
ibx => $ibx,
};
diff --git a/t/psgi_mount.t b/t/psgi_mount.t
index b4de827406b70a62c279454e73e882e617d9ec32..dac62c1a2962a48cfcb77078888c3742f843e1be 100644
--- a/t/psgi_mount.t
+++ b/t/psgi_mount.t
@@ -17,7 +17,7 @@ use_ok 'PublicInbox::WWW';
use PublicInbox::Import;
use PublicInbox::Git;
use PublicInbox::Config;
-my $config = PublicInbox::Config->new(\<new(\<add($mime);
$im->done;
}
-my $www = PublicInbox::WWW->new($config);
+my $www = PublicInbox::WWW->new($cfg);
my $app = builder(sub {
enable('Head');
mount('/a' => builder(sub { sub { $www->call(@_) } }));
@@ -85,7 +85,7 @@ });
SKIP: {
require_mods(qw(DBD::SQLite Search::Xapian IO::Uncompress::Gunzip), 3);
- my $ibx = $config->lookup_name('test');
+ my $ibx = $cfg->lookup_name('test');
require_ok 'PublicInbox::SearchIdx';
PublicInbox::SearchIdx->new($ibx, 1)->index_sync;
test_psgi($app, sub {
diff --git a/t/psgi_search.t b/t/psgi_search.t
index c1677eb33bf8a101de2e40aedf8768cf8475fbbf..07fb48466bf788b060f02fd9f25614347e36c2d7 100644
--- a/t/psgi_search.t
+++ b/t/psgi_search.t
@@ -67,11 +67,11 @@ $im->done;
PublicInbox::SearchIdx->new($ibx, 1)->index_sync;
my $cfgpfx = "publicinbox.test";
-my $config = PublicInbox::Config->new(\<new(\<new($config);
+my $www = PublicInbox::WWW->new($cfg);
test_psgi(sub { $www->call(@_) }, sub {
my ($cb) = @_;
my $res;
@@ -144,7 +144,7 @@ my $xdb = $sidx->idx_acquire;
$xdb->set_metadata('has_threadid', '0');
$sidx->idx_release;
}
- $config->each_inbox(sub { delete $_[0]->{search} });
+ $cfg->each_inbox(sub { delete $_[0]->{search} });
$res = $cb->(GET('/test/?q=s:test'));
is($res->code, 200, 'successful search w/o has_threadid');
unlike($html, qr/download mbox\.gz: .*?"full threads"/s,
diff --git a/t/psgi_v2.t b/t/psgi_v2.t
index 11aef5b3380c9c860e50161ae6e83fa83f27af6a..0ceb26ed8c9bdbaf4b1f15ef550f35c8511864e2 100644
--- a/t/psgi_v2.t
+++ b/t/psgi_v2.t
@@ -83,12 +83,11 @@ like($$msg, qr/\AFrom oldbug/s,
'"From_" line stored to test old bug workaround');
my $cfgpfx = "publicinbox.v2test";
-my $cfg = <new(\<{-primary_address}
$cfgpfx.inboxdir=$inboxdir
EOF
-my $config = PublicInbox::Config->new(\$cfg);
-my $www = PublicInbox::WWW->new($config);
+my $www = PublicInbox::WWW->new($cfg);
my ($res, $raw, @from_);
my $client0 = sub {
my ($cb) = @_;
@@ -150,7 +149,7 @@ like($raw, qr/^hello world!$/m, 'got second message');
like($raw, qr/^hello ghosts$/m, 'got third message');
@from_ = ($raw =~ m/^From /mg);
is(scalar(@from_), 3, 'three From_ lines');
- $config->each_inbox(sub { $_[0]->search->reopen });
+ $cfg->each_inbox(sub { $_[0]->search->reopen });
SKIP: {
eval { require IO::Uncompress::Gunzip };
@@ -240,7 +239,7 @@ ok($im->add($mime), 'added one message');
$im->done;
my @h = $mime->header('Message-ID');
is_deeply($exp, \@h, 'reused existing Message-ID');
- $config->each_inbox(sub { $_[0]->search->reopen });
+ $cfg->each_inbox(sub { $_[0]->search->reopen });
}
my $client2 = sub {
@@ -279,7 +278,7 @@ $mime = eml_load "t/psgi_v2-$body.eml";
ok($im->add($mime), "added attachment $body");
}
$im->done;
- $config->each_inbox(sub { $_[0]->search->reopen });
+ $cfg->each_inbox(sub { $_[0]->search->reopen });
}
my $client3 = sub {
diff --git a/t/watch_filter_rubylang.t b/t/watch_filter_rubylang.t
index 6513f30b0441c42d0fa63366d79b4973e98e9260..9c70b4eae710990f1eebddd5301434c3eb5213bb 100644
--- a/t/watch_filter_rubylang.t
+++ b/t/watch_filter_rubylang.t
@@ -72,11 +72,11 @@ $cfgpfx.filter=PublicInbox::Filter::RubyLang
$cfgpfx.altid=serial:alerts:file=msgmap.sqlite3
publicinboxwatch.watchspam=maildir:$spamdir
EOF
- my $config = PublicInbox::Config->new(\$orig);
- my $ibx = $config->lookup_name($v);
+ my $cfg = PublicInbox::Config->new(\$orig);
+ my $ibx = $cfg->lookup_name($v);
ok($ibx, 'found inbox by name');
- my $w = PublicInbox::Watch->new($config);
+ my $w = PublicInbox::Watch->new($cfg);
for my $i (1..2) {
$w->scan('full');
}
@@ -101,8 +101,8 @@ is(unlink($new[0]), 1);
}
$w->scan('full');
- $config = PublicInbox::Config->new(\$orig);
- $ibx = $config->lookup_name($v);
+ $cfg = PublicInbox::Config->new(\$orig);
+ $ibx = $cfg->lookup_name($v);
is($ibx->search->reopen->mset('b:spam')->size, 0, 'spam removed');
is_deeply([], \@warn, 'no warnings');
diff --git a/t/watch_maildir.t b/t/watch_maildir.t
index ae53caf92f11ca26f4fd7baa3ed9f29fa07186f0..c948b41b235334bffbe5a47c06f57866c64f1426 100644
--- a/t/watch_maildir.t
+++ b/t/watch_maildir.t
@@ -34,13 +34,13 @@
{
my @w;
local $SIG{__WARN__} = sub { push @w, @_ };
- my $config = PublicInbox::Config->new(\<new(\<new($config);
+ my $wm = PublicInbox::Watch->new($cfg);
is(scalar grep(/is a spam folder/, @w), 1, 'got warning about spam');
is_deeply($wm->{mdmap}, { "$spamdir/cur" => 'watchspam' },
'only got the spam folder to watch');
@@ -61,8 +61,8 @@ EOF
close $fh or BAIL_OUT $!;
}
-my $config = PublicInbox::Config->new($cfg_path);
-PublicInbox::Watch->new($config)->scan('full');
+my $cfg = PublicInbox::Config->new($cfg_path);
+PublicInbox::Watch->new($cfg)->scan('full');
my $git = PublicInbox::Git->new($git_dir);
my @list = $git->qx(qw(rev-list refs/heads/master));
is(scalar @list, 1, 'one revision in rev-list');
@@ -79,7 +79,7 @@ is(unlink($new[0]), 1);
};
$write_spam->();
is(unlink(glob("$maildir/new/*")), 1, 'unlinked old spam');
-PublicInbox::Watch->new($config)->scan('full');
+PublicInbox::Watch->new($cfg)->scan('full');
@list = $git->qx(qw(rev-list refs/heads/master));
is(scalar @list, 2, 'two revisions in rev-list');
@list = $git->qx(qw(ls-tree -r --name-only refs/heads/master));
@@ -93,7 +93,7 @@ To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo\@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html\n);
PublicInbox::Emergency->new($maildir)->prepare(\$msg);
- PublicInbox::Watch->new($config)->scan('full');
+ PublicInbox::Watch->new($cfg)->scan('full');
@list = $git->qx(qw(ls-tree -r --name-only refs/heads/master));
is(scalar @list, 1, 'tree has one file');
my $mref = $git->cat_file('HEAD:'.$list[0]);
@@ -101,7 +101,7 @@ like($$mref, qr/something\n\z/s, 'message scrubbed on import');
is(unlink(glob("$maildir/new/*")), 1, 'unlinked spam');
$write_spam->();
- PublicInbox::Watch->new($config)->scan('full');
+ PublicInbox::Watch->new($cfg)->scan('full');
@list = $git->qx(qw(ls-tree -r --name-only refs/heads/master));
is(scalar @list, 0, 'tree is empty');
@list = $git->qx(qw(rev-list refs/heads/master));
@@ -115,10 +115,10 @@ ok(-x "$fail_bin/spamc", "mock spamc exists");
my $fail_path = "$fail_bin:$ENV{PATH}"; # for spamc ham mock
local $ENV{PATH} = $fail_path;
PublicInbox::Emergency->new($maildir)->prepare(\$msg);
- $config->{'publicinboxwatch.spamcheck'} = 'spamc';
+ $cfg->{'publicinboxwatch.spamcheck'} = 'spamc';
{
local $SIG{__WARN__} = sub {}; # quiet spam check warning
- PublicInbox::Watch->new($config)->scan('full');
+ PublicInbox::Watch->new($cfg)->scan('full');
}
@list = $git->qx(qw(ls-tree -r --name-only refs/heads/master));
is(scalar @list, 0, 'tree has no files spamc checked');
@@ -131,9 +131,9 @@ ok(-x "$main_bin/spamc", "mock spamc exists");
my $main_path = "$main_bin:$ENV{PATH}"; # for spamc ham mock
local $ENV{PATH} = $main_path;
PublicInbox::Emergency->new($maildir)->prepare(\$msg);
- $config->{'publicinboxwatch.spamcheck'} = 'spamc';
+ $cfg->{'publicinboxwatch.spamcheck'} = 'spamc';
@list = $git->qx(qw(ls-tree -r --name-only refs/heads/master));
- PublicInbox::Watch->new($config)->scan('full');
+ PublicInbox::Watch->new($cfg)->scan('full');
@list = $git->qx(qw(ls-tree -r --name-only refs/heads/master));
is(scalar @list, 1, 'tree has one file after spamc checked');
@@ -166,9 +166,9 @@ diag "message delivered to `$ibx->{name}'";
$delivered++;
};
PublicInbox::DS->Reset;
- my $ii = PublicInbox::InboxIdle->new($config);
+ my $ii = PublicInbox::InboxIdle->new($cfg);
my $obj = bless \$cb, 'PublicInbox::TestCommon::InboxWakeup';
- $config->each_inbox(sub { $_[0]->subscribe_unlock('ident', $obj) });
+ $cfg->each_inbox(sub { $_[0]->subscribe_unlock('ident', $obj) });
PublicInbox::DS->SetPostLoopCallback(sub { $delivered == 0 });
# wait for -watch to setup inotify watches
diff --git a/t/watch_maildir_v2.t b/t/watch_maildir_v2.t
index 125464182a82832c14f426affe39b4701fdd234c..532e5c7cca9fba16f1a81b34c8ab2c66e3be358b 100644
--- a/t/watch_maildir_v2.t
+++ b/t/watch_maildir_v2.t
@@ -44,11 +44,11 @@ $cfgpfx.watch=maildir:$maildir
$cfgpfx.filter=PublicInbox::Filter::Vger
publicinboxlearn.watchspam=maildir:$spamdir
EOF
-my $config = PublicInbox::Config->new(\$orig);
-my $ibx = $config->lookup_name('test');
+my $cfg = PublicInbox::Config->new(\$orig);
+my $ibx = $cfg->lookup_name('test');
ok($ibx, 'found inbox by name');
-PublicInbox::Watch->new($config)->scan('full');
+PublicInbox::Watch->new($cfg)->scan('full');
my $total = scalar @{$ibx->over->recent};
is($total, 1, 'got one revision');
@@ -68,7 +68,7 @@ is(unlink($new[0]), 1);
};
$write_spam->();
is(unlink(glob("$maildir/new/*")), 1, 'unlinked old spam');
-PublicInbox::Watch->new($config)->scan('full');
+PublicInbox::Watch->new($cfg)->scan('full');
is_deeply($ibx->over->recent, [], 'deleted file');
is(unlink(glob("$spamdir/cur/*")), 1, 'unlinked trained spam');
@@ -79,7 +79,7 @@ To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo\@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html\n);
PublicInbox::Emergency->new($maildir)->prepare(\$msg);
- PublicInbox::Watch->new($config)->scan('full');
+ PublicInbox::Watch->new($cfg)->scan('full');
my $msgs = $ibx->over->recent;
is(scalar(@$msgs), 1, 'got one file back');
my $mref = $ibx->msg_by_smsg($msgs->[0]);
@@ -87,7 +87,7 @@ like($$mref, qr/something\n\z/s, 'message scrubbed on import');
is(unlink(glob("$maildir/new/*")), 1, 'unlinked spam');
$write_spam->();
- PublicInbox::Watch->new($config)->scan('full');
+ PublicInbox::Watch->new($cfg)->scan('full');
$msgs = $ibx->over->recent;
is(scalar(@$msgs), 0, 'inbox is empty again');
is(unlink(glob("$spamdir/cur/*")), 1, 'unlinked trained spam');
@@ -99,10 +99,10 @@ ok(-x "$fail_bin/spamc", "mock spamc exists");
my $fail_path = "$fail_bin:$ENV{PATH}"; # for spamc ham mock
local $ENV{PATH} = $fail_path;
PublicInbox::Emergency->new($maildir)->prepare(\$msg);
- $config->{'publicinboxwatch.spamcheck'} = 'spamc';
+ $cfg->{'publicinboxwatch.spamcheck'} = 'spamc';
{
local $SIG{__WARN__} = sub {}; # quiet spam check warning
- PublicInbox::Watch->new($config)->scan('full');
+ PublicInbox::Watch->new($cfg)->scan('full');
}
my $msgs = $ibx->over->recent;
is(scalar(@$msgs), 0, 'inbox is still empty');
@@ -115,13 +115,13 @@ ok(-x "$main_bin/spamc", "mock spamc exists");
my $main_path = "$main_bin:$ENV{PATH}"; # for spamc ham mock
local $ENV{PATH} = $main_path;
PublicInbox::Emergency->new($maildir)->prepare(\$msg);
- $config->{'publicinboxwatch.spamcheck'} = 'spamc';
- PublicInbox::Watch->new($config)->scan('full');
+ $cfg->{'publicinboxwatch.spamcheck'} = 'spamc';
+ PublicInbox::Watch->new($cfg)->scan('full');
my $msgs = $ibx->over->recent;
is(scalar(@$msgs), 1, 'inbox has one mail after spamc OK-ed a message');
my $mref = $ibx->msg_by_smsg($msgs->[0]);
like($$mref, qr/something\n\z/s, 'message scrubbed on import');
- delete $config->{'publicinboxwatch.spamcheck'};
+ delete $cfg->{'publicinboxwatch.spamcheck'};
}
{
@@ -129,7 +129,7 @@ my $patch = 't/data/0001.patch';
open my $fh, '<', $patch or die "failed to open $patch: $!\n";
$msg = do { local $/; <$fh> };
PublicInbox::Emergency->new($maildir)->prepare(\$msg);
- PublicInbox::Watch->new($config)->scan('full');
+ PublicInbox::Watch->new($cfg)->scan('full');
my $post = $ibx->search->reopen->mset('dfpost:6e006fd7');
is($post->size, 1, 'diff postimage found');
my $pre = $ibx->search->mset('dfpre:090d998b6c2c');
@@ -146,12 +146,12 @@ my $v1repo = "$tmpdir/v1";
my $v1pfx = "publicinbox.v1";
my $v1addr = 'v1-public@example.com';
PublicInbox::Import::init_bare($v1repo);
- my $cfg2 = <new(\$cfg2);
+ my $cfg = PublicInbox::Config->new(\$raw);
my $both = <new($maildir)->prepare(\$both);
- PublicInbox::Watch->new($config)->scan('full');
+ PublicInbox::Watch->new($cfg)->scan('full');
my $mset = $ibx->search->reopen->mset('m:both@b.com');
my $msgs = $ibx->search->mset_to_smsg($ibx, $mset);
- my $v1 = $config->lookup_name('v1');
+ my $v1 = $cfg->lookup_name('v1');
my $msg = $v1->git->cat_file($msgs->[0]->{blob});
is($both, $$msg, 'got original message back from v1');
$msg = $ibx->git->cat_file($msgs->[0]->{blob});
@@ -184,21 +184,21 @@ List-Id:
X-Mailing-List: no@example.com
Message-ID:
EOF
- my $cfg = $orig."$cfgpfx.listid=i.want.you.to.want.me\n";
+ my $raw = $orig."$cfgpfx.listid=i.want.you.to.want.me\n";
PublicInbox::Emergency->new($maildir)->prepare(\$want);
PublicInbox::Emergency->new($maildir)->prepare(\$do_not_want);
- my $config = PublicInbox::Config->new(\$cfg);
- PublicInbox::Watch->new($config)->scan('full');
- $ibx = $config->lookup_name('test');
+ my $cfg = PublicInbox::Config->new(\$raw);
+ PublicInbox::Watch->new($cfg)->scan('full');
+ $ibx = $cfg->lookup_name('test');
my $num = $ibx->mm->num_for('do.want@example.com');
ok(defined $num, 'List-ID matched for watch');
$num = $ibx->mm->num_for('do.not.want@example.com');
is($num, undef, 'unaccepted List-ID matched for watch');
- $cfg = $orig."$cfgpfx.watchheader=X-Mailing-List:no\@example.com\n";
- $config = PublicInbox::Config->new(\$cfg);
- PublicInbox::Watch->new($config)->scan('full');
- $ibx = $config->lookup_name('test');
+ $raw = $orig."$cfgpfx.watchheader=X-Mailing-List:no\@example.com\n";
+ $cfg = PublicInbox::Config->new(\$raw);
+ PublicInbox::Watch->new($cfg)->scan('full');
+ $ibx = $cfg->lookup_name('test');
$num = $ibx->mm->num_for('do.not.want@example.com');
ok(defined $num, 'X-Mailing-List matched');
}
diff --git a/t/watch_multiple_headers.t b/t/watch_multiple_headers.t
index a081353210275b4d38b5256f92c2dda3c85ea285..1fe392d48a25faef09a474e72533922f3bb7805d 100644
--- a/t/watch_multiple_headers.t
+++ b/t/watch_multiple_headers.t
@@ -54,16 +54,16 @@ PublicInbox::Emergency->new($maildir)->prepare(\$msg_to);
PublicInbox::Emergency->new($maildir)->prepare(\$msg_cc);
PublicInbox::Emergency->new($maildir)->prepare(\$msg_none);
-my $cfg = <new(\$cfg);
-PublicInbox::Watch->new($config)->scan('full');
-my $ibx = $config->lookup_name('test');
+my $cfg = PublicInbox::Config->new(\$raw);
+PublicInbox::Watch->new($cfg)->scan('full');
+my $ibx = $cfg->lookup_name('test');
ok($ibx, 'found inbox by name');
my $num = $ibx->mm->num_for('to@a.com');