]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/Msgmap.pm
get rid of unnecessary bytes::length usage
[public-inbox.git] / lib / PublicInbox / Msgmap.pm
index d696ce837395bcbc0800a09e41290f8f1e5fee02..16a9a476407f7ff30b722c7501d85a76d6f5c842 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (C) 2015-2020 all contributors <meta@public-inbox.org>
+# Copyright (C) 2015-2021 all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 
 # bidirectional Message-ID <-> Article Number mapping for the NNTP
@@ -36,8 +36,7 @@ sub new_file {
                create_tables($dbh);
                $self->created_at(time) unless $self->created_at;
 
-               my $max = $self->max // 0;
-               $self->num_highwater($max);
+               $self->num_highwater(max($self));
                $dbh->commit;
        }
        $self;
@@ -47,7 +46,7 @@ sub new_file {
 sub tmp_clone {
        my ($self, $dir) = @_;
        require File::Temp;
-       my $tmp = "mm_tmp-$$-XXXXXX";
+       my $tmp = "mm_tmp-$$-XXXX";
        my ($fh, $fn) = File::Temp::tempfile($tmp, EXLOCK => 0, DIR => $dir);
        PublicInbox::Spawn::nodatacow_fd(fileno($fh));
        $self->{dbh}->sqlite_backup_to_file($fn);
@@ -91,6 +90,7 @@ sub last_commit_xap {
        $self->meta_accessor("last_xap$version-$i", $commit);
 }
 
+# this is the UIDVALIDITY for IMAP (cf. RFC 3501 sec 2.3.1.1. item 3)
 sub created_at {
        my ($self, $second) = @_;
        $self->meta_accessor('created_at', $second);
@@ -143,7 +143,7 @@ sub max {
        my $sth = $_[0]->{dbh}->prepare_cached('SELECT MAX(num) FROM msgmap',
                                                undef, 1);
        $sth->execute;
-       $sth->fetchrow_array;
+       $sth->fetchrow_array // 0;
 }
 
 sub minmax {
@@ -152,7 +152,7 @@ sub minmax {
        my $sth = $_[0]->{dbh}->prepare_cached('SELECT MIN(num) FROM msgmap',
                                                undef, 1);
        $sth->execute;
-       ($sth->fetchrow_array, max($_[0]));
+       ($sth->fetchrow_array // 0, max($_[0]));
 }
 
 sub mid_delete {