}
bless $self, $class;
# caches
- $self->{-by_addr} ||= {};
- $self->{-by_list_id} ||= {};
- $self->{-by_name} ||= {};
- $self->{-by_newsgroup} ||= {};
- $self->{-no_obfuscate} ||= {};
- $self->{-limiters} ||= {};
- $self->{-code_repos} ||= {}; # nick => PublicInbox::Git object
+ $self->{-by_addr} = {};
+ $self->{-by_list_id} = {};
+ $self->{-by_name} = {};
+ $self->{-by_newsgroup} = {};
+ $self->{-no_obfuscate} = {};
+ $self->{-limiters} = {};
+ $self->{-code_repos} = {}; # nick => PublicInbox::Git object
$self->{-cgitrc_unparsed} = $self->{'publicinbox.cgitrc'};
if (my $no = delete $self->{'publicinbox.noobfuscate'}) {
sub lookup_name ($$) {
my ($self, $name) = @_;
- $self->{-by_name}->{$name} || _fill($self, "publicinbox.$name");
+ $self->{-by_name}->{$name} // _fill($self, "publicinbox.$name");
}
sub each_inbox {
# may auto-vivify if config file is non-existent:
foreach my $section (@{$self->{-section_order}}) {
next if $section !~ m!\Apublicinbox\.([^/]+)\z!;
- $self->{"publicinbox.$1.mainrepo"} or next;
my $ibx = lookup_name($self, $1) or next;
$cb->($ibx);
}
sub limiter {
my ($self, $name) = @_;
- $self->{-limiters}->{$name} ||= do {
+ $self->{-limiters}->{$name} //= do {
require PublicInbox::Qspawn;
my $max = $self->{"publicinboxlimiter.$name.max"} || 1;
my $limiter = PublicInbox::Qspawn::Limiter->new($max);
};
}
-sub config_dir { $ENV{PI_DIR} || "$ENV{HOME}/.public-inbox" }
+sub config_dir { $ENV{PI_DIR} // "$ENV{HOME}/.public-inbox" }
sub default_file {
my $f = $ENV{PI_CONFIG};
$self->{-cgit_remove_suffix} and
$rel =~ s!/?\.git\z!!;
}
- $self->{"coderepo.$rel.dir"} ||= $path;
- $self->{"coderepo.$rel.cgiturl"} ||= $rel;
+ $self->{"coderepo.$rel.dir"} //= $path;
+ $self->{"coderepo.$rel.cgiturl"} //= $rel;
}
sub is_git_dir ($) {
# cgit supports "/blob/?id=%s", but it's only a plain-text
# display and requires an unabbreviated id=
foreach my $t (qw(blob commit tag)) {
- $git->{$t.'_url_format'} ||= map {
+ $git->{$t.'_url_format'} //= map {
"$_/$t/?id=%s"
} @$cgits;
}
my ($self, $pfx) = @_;
my $ibx = {};
- foreach my $k (qw(mainrepo filter url newsgroup
+ foreach my $k (qw(inboxdir filter url newsgroup
infourl watch watchheader httpbackendmax
replyto feedmax nntpserver indexlevel)) {
my $v = $self->{"$pfx.$k"};
$ibx->{$k} = $v if defined $v;
}
+
+ # backwards compatibility:
+ $ibx->{inboxdir} //= $self->{"$pfx.mainrepo"};
+
foreach my $k (qw(obfuscate)) {
my $v = $self->{"$pfx.$k"};
defined $v or next;
}
}
- return unless $ibx->{mainrepo};
+ return unless defined($ibx->{inboxdir});
my $name = $pfx;
$name =~ s/\Apublicinbox\.//;
$valid += valid_inbox_name($_) foreach (@parts);
$valid == scalar(@parts) or next;
- my $repo = $code_repos->{$nick} ||=
+ my $repo = $code_repos->{$nick} //=
_fill_code_repo($self, $nick);
push @$repo_objs, $repo if $repo;
}