From eea4ba7bac73b67ccd2cdd07946b176260ac5fac Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 21 Dec 2020 07:51:18 +0000 Subject: inbox: delay ->version detection Our read-only code won't need to know the version until an inbox is accessed. This is a small step towards eliminating many stat() calls on read-only daemon startup. --- lib/PublicInbox/Inbox.pm | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'lib/PublicInbox/Inbox.pm') diff --git a/lib/PublicInbox/Inbox.pm b/lib/PublicInbox/Inbox.pm index 8a3a0194..863a5de4 100644 --- a/lib/PublicInbox/Inbox.pm +++ b/lib/PublicInbox/Inbox.pm @@ -109,10 +109,6 @@ sub new { delete $opts->{feedmax}; } $opts->{nntpserver} ||= $pi_cfg->{'publicinbox.nntpserver'}; - my $dir = $opts->{inboxdir}; - if (defined $dir && -f "$dir/inbox.lock") { - $opts->{version} = 2; - } # allow any combination of multi-line or comma-delimited hide entries my $hide = {}; @@ -125,7 +121,9 @@ sub new { bless $opts, $class; } -sub version { $_[0]->{version} // 1 } +sub version { + $_[0]->{version} //= -f "$_[0]->{inboxdir}/inbox.lock" ? 2 : 1 +} sub git_epoch { my ($self, $epoch) = @_; # v2-only, callers always supply $epoch -- cgit v1.2.3-24-ge0c7