about summary refs log tree commit homepage
path: root/lib/PublicInbox/Msgmap.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/PublicInbox/Msgmap.pm')
-rw-r--r--lib/PublicInbox/Msgmap.pm26
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/PublicInbox/Msgmap.pm b/lib/PublicInbox/Msgmap.pm
index d115cbce..aa07e344 100644
--- a/lib/PublicInbox/Msgmap.pm
+++ b/lib/PublicInbox/Msgmap.pm
@@ -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;