]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
init: move --skip-epoch handling to {-creat_opt}
authorEric Wong <e@80x24.org>
Sat, 18 Jan 2025 01:26:07 +0000 (01:26 +0000)
committerEric Wong <e@80x24.org>
Tue, 21 Jan 2025 22:36:57 +0000 (22:36 +0000)
Epoch skipping only makes sense at inbox creation, thus we'll
bundle inbox creation options together to reduce potentionally
confusing positional parameters.

lib/PublicInbox/InboxWritable.pm
lib/PublicInbox/V2Writable.pm
script/public-inbox-init

index a8239f4919fd398150fdf5d8239b585e85dd2186..f69aec75460377832bd1cc95c3614e4e9a3ec7b7 100644 (file)
@@ -50,13 +50,13 @@ sub _init_v1 {
 }
 
 sub init_inbox {
-       my ($self, $shards, $skip_epoch) = @_;
+       my ($self, $shards) = @_;
        if ($self->version == 1) {
                my $dir = assert_usable_dir($self);
                PublicInbox::Import::init_bare($dir);
                $self->with_umask(\&_init_v1, $self);
        } else {
-               importer($self)->init_inbox($shards, $skip_epoch);
+               importer($self)->init_inbox($shards);
        }
 }
 
index b62d0477efffb85488cd141fc1373a0f152153f5..73c6dcccf849f415642d07dfe7bb5b07494a3331 100644 (file)
@@ -76,12 +76,13 @@ sub new {
 
 # public (for now?)
 sub init_inbox {
-       my ($self, $shards, $skip_epoch) = @_;
+       my ($self, $shards) = @_;
        if (defined $shards) {
                $self->{parallel} = 0 if $shards == 0;
                $self->{shards} = $shards if $shards > 0;
        }
        my $max = $self->{ibx}->max_git_epoch;
+       my $skip_epoch = ($self->{ibx}->{-creat_opt} // {})->{'skip-epoch'};
        $max = $skip_epoch if (defined($skip_epoch) && !defined($max));
        $self->{mg}->add_epoch($max // 0);
        $self->idx_init;
index 1e479a3ac597aef35e4a928d9e52887dda681415..b3f60bad7e3fd9d13440999cc5157fe0f6c2f57d 100755 (executable)
@@ -34,7 +34,7 @@ EOF
 require PublicInbox::Admin;
 PublicInbox::Admin::require_or_die('-base');
 
-my ($version, $indexlevel, $skip_epoch, $jobs, $show_help);
+my ($version, $indexlevel, $jobs, $show_help);
 my $skip_docdata;
 my $ng = '';
 my (@c_extra, @chdir);
@@ -42,7 +42,7 @@ my $creat_opt = {};
 my %opts = (
        'V|version=i' => \$version,
        'L|index-level|indexlevel=s' => \$indexlevel,
-       'S|skip|skip-epoch=i' => \$skip_epoch,
+       'S|skip|skip-epoch=i' => \($creat_opt->{'skip-epoch'}),
        'skip-artnum=i' => \($creat_opt->{'skip-artnum'}),
        'j|jobs=i' => \$jobs,
        'ng|newsgroup=s' => \$ng,
@@ -184,7 +184,7 @@ if (-f "$inboxdir/inbox.lock") {
 
 $version = 1 unless defined $version;
 
-if ($version == 1 && defined $skip_epoch) {
+if ($version == 1 && defined $creat_opt->{'skip-epoch'}) {
        die "--skip-epoch is only supported for -V2 inboxes\n";
 }
 
@@ -210,7 +210,7 @@ if ($skip_docdata) {
                die "--skip-docdata ignored with --indexlevel=basic\n";
        $ibx->{-skip_docdata} = $skip_docdata;
 }
-$ibx->init_inbox(0, $skip_epoch);
+$ibx->init_inbox(0);
 
 my $f = "$inboxdir/description";
 if (sysopen $fh, $f, O_CREAT|O_EXCL|O_WRONLY) {