]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/Msgmap.pm
rename {pi_config} fields to {pi_cfg}
[public-inbox.git] / lib / PublicInbox / Msgmap.pm
index d28e96c8588b002e62a09b64dc6eaaad51346309..a8c874af32487bcdd64bdc1b2d5ef1093e7ae933 100644 (file)
@@ -6,9 +6,10 @@
 # numbers for NNTP and allows prefix lookups for partial Message-IDs
 # in case URLs get truncated from copy-n-paste errors by users.
 #
-# This is maintained by ::SearchIdx
+# This is maintained by ::SearchIdx (v1) and ::V2Writable (v2)
 package PublicInbox::Msgmap;
 use strict;
+use v5.10.1;
 use DBI;
 use DBD::SQLite;
 use PublicInbox::Over;
@@ -35,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;
@@ -90,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);
@@ -142,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 {
@@ -151,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 {