diff options
author | Eric Wong <e@80x24.org> | 2020-12-21 07:51:18 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2020-12-21 21:51:55 +0000 |
commit | eea4ba7bac73b67ccd2cdd07946b176260ac5fac (patch) | |
tree | 7865b5df209c69794ed7c16fbc9370d794d151e3 /lib/PublicInbox/Inbox.pm | |
parent | 3ce4c38119f13d419bb865a0aa9b66feff339308 (diff) | |
download | public-inbox-eea4ba7bac73b67ccd2cdd07946b176260ac5fac.tar.gz |
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.
Diffstat (limited to 'lib/PublicInbox/Inbox.pm')
-rw-r--r-- | lib/PublicInbox/Inbox.pm | 8 |
1 files changed, 3 insertions, 5 deletions
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 |