]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/Msgmap.pm
init: add --skip-artnum parameter
[public-inbox.git] / lib / PublicInbox / Msgmap.pm
index d115cbce352cd3551b406d5b5c9d90782e9feab1..aa07e344c6a9d75a9b376af5a6fbbd5911481198 100644 (file)
@@ -270,4 +270,30 @@ sub atfork_prepare {
        %$self = (tmp_name => $f, pid => $$);
 }
 
+sub skip_artnum {
+       my ($self, $skip_artnum) = @_;
+       return meta_accessor($self, 'skip_artnum') if !defined($skip_artnum);
+
+       my $cur = num_highwater($self) // 0;
+       if ($skip_artnum < $cur) {
+               die "E: current article number $cur ",
+                       "exceeds --skip-artnum=$skip_artnum\n";
+       } else {
+               my $ok;
+               for (1..10) {
+                       my $mid = 'skip'.rand.'@'.rand.'.example.com';
+                       $ok = mid_set($self, $skip_artnum, $mid);
+                       if ($ok) {
+                               mid_delete($self, $mid);
+                               last;
+                       }
+               }
+               $ok or die '--skip-artnum failed';
+
+               # in the future, the indexer may use this value for
+               # new messages in old epochs
+               meta_accessor($self, 'skip_artnum', $skip_artnum);
+       }
+}
+
 1;