about summary refs log tree commit homepage
path: root/lib/PublicInbox/InboxWritable.pm
diff options
context:
space:
mode:
authorEric Wong <e@yhbt.net>2020-06-21 00:21:33 +0000
committerEric Wong <e@yhbt.net>2020-06-23 00:22:18 +0000
commit5759c29ba5e0c8b2b1135e528e133dc7dde219f8 (patch)
tree841e315a7c4c54910bcc72868f4eb92a51fcc092 /lib/PublicInbox/InboxWritable.pm
parent3ba0028804c50b75b1854d0c2bf637ebce0aa8b1 (diff)
downloadpublic-inbox-5759c29ba5e0c8b2b1135e528e133dc7dde219f8.tar.gz
For archivists with only newer mail archives, this option allows
reserving reserve NNTP article numbers for yet-to-be-archived
old messages.  Indexers will need to be updated to support this
feature in future commits.

-V1 inboxes will now be initialized with SQLite and Xapian
support if this option is used, or if --indexlevel= is
specified.
Diffstat (limited to 'lib/PublicInbox/InboxWritable.pm')
-rw-r--r--lib/PublicInbox/InboxWritable.pm13
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/PublicInbox/InboxWritable.pm b/lib/PublicInbox/InboxWritable.pm
index c54be046..f9e28502 100644
--- a/lib/PublicInbox/InboxWritable.pm
+++ b/lib/PublicInbox/InboxWritable.pm
@@ -39,10 +39,21 @@ sub assert_usable_dir {
 
 sub init_inbox {
         my ($self, $shards, $skip_epoch, $skip_artnum) = @_;
-        # TODO: honor skip_artnum
         if ($self->version == 1) {
                 my $dir = assert_usable_dir($self);
                 PublicInbox::Import::init_bare($dir);
+                if (defined($self->{indexlevel}) || defined($skip_artnum)) {
+                        require PublicInbox::SearchIdx;
+                        my $sidx = PublicInbox::SearchIdx->new($self, 1); # just create
+                        $sidx->begin_txn_lazy;
+                        $self->with_umask(sub {
+                                my $mm = PublicInbox::Msgmap->new($dir, 1);
+                                $mm->{dbh}->begin_work;
+                                $mm->skip_artnum($skip_artnum);
+                                $mm->{dbh}->commit;
+                        }) if defined($skip_artnum);
+                        $sidx->commit_txn_lazy;
+                }
         } else {
                 my $v2w = importer($self);
                 $v2w->init_inbox($shards, $skip_epoch, $skip_artnum);