diff options
author | Eric Wong <e@yhbt.net> | 2020-01-26 01:17:42 +0000 |
---|---|---|
committer | Eric Wong <e@yhbt.net> | 2020-01-27 02:58:06 +0000 |
commit | 227a1d886672767e37cc86a3432952c14eb8a143 (patch) | |
tree | dd4890655f88583a16952c751cf9f4e9e731d224 /lib/PublicInbox/InboxWritable.pm | |
parent | fcfa0d639da338c470f07942da71f78fa65354a1 (diff) | |
download | public-inbox-227a1d886672767e37cc86a3432952c14eb8a143.tar.gz |
inbox: add ->version method
This allows us to simplify version checking by avoiding "//" or "||" operators sprinkled around.
Diffstat (limited to 'lib/PublicInbox/InboxWritable.pm')
-rw-r--r-- | lib/PublicInbox/InboxWritable.pm | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/lib/PublicInbox/InboxWritable.pm b/lib/PublicInbox/InboxWritable.pm index 228e786c..5b2aeed3 100644 --- a/lib/PublicInbox/InboxWritable.pm +++ b/lib/PublicInbox/InboxWritable.pm @@ -24,7 +24,7 @@ sub new { # TODO: maybe stop supporting this if ($creat_opt) { # for { nproc => $N } $self->{-creat_opt} = $creat_opt; - init_inbox($self) if ($self->{version} || 1) == 1; + init_inbox($self) if $self->version == 1; } $self; } @@ -39,8 +39,7 @@ sub assert_usable_dir { sub init_inbox { my ($self, $shards, $skip_epoch, $skip_artnum) = @_; # TODO: honor skip_artnum - my $v = $self->{version} || 1; - if ($v == 1) { + if ($self->version == 1) { my $dir = assert_usable_dir($self); PublicInbox::Import::init_bare($dir); } else { @@ -51,7 +50,7 @@ sub init_inbox { sub importer { my ($self, $parallel) = @_; - my $v = $self->{version} || 1; + my $v = $self->version; if ($v == 2) { eval { require PublicInbox::V2Writable }; die "v2 not supported: $@\n" if $@; @@ -75,7 +74,7 @@ sub filter { # v2 keeps msgmap open, which causes conflicts for filters # such as PublicInbox::Filter::RubyLang which overload msgmap # for a predictable serial number. - if ($im && ($self->{version} || 1) >= 2 && $self->{altid}) { + if ($im && $self->version >= 2 && $self->{altid}) { $im->done; } |