]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/V2Writable.pm
wwwstream: show relative coderepo URLs correctly
[public-inbox.git] / lib / PublicInbox / V2Writable.pm
index 572eb4184bafc2a86e1c787b12e3855bc1a799a5..3e3b275f995f44e6a1403bdc382e71cbae213451 100644 (file)
@@ -128,12 +128,9 @@ sub init_inbox {
        }
        $self->idx_init;
        $self->{mm}->skip_artnum($skip_artnum) if defined $skip_artnum;
-       my $epoch_max = -1;
-       $self->{ibx}->git_dir_latest(\$epoch_max);
-       if (defined $skip_epoch && $epoch_max == -1) {
-               $epoch_max = $skip_epoch;
-       }
-       $self->git_init($epoch_max >= 0 ? $epoch_max : 0);
+       my $max = $self->{ibx}->max_git_epoch;
+       $max = $skip_epoch if (defined($skip_epoch) && !defined($max));
+       $self->git_init($max // 0);
        $self->done;
 }
 
@@ -336,12 +333,7 @@ sub _replace_oids ($$$) {
        my $ibx = $self->{ibx};
        my $pfx = "$ibx->{inboxdir}/git";
        my $rewrites = []; # epoch => commit
-       my $max = $self->{epoch_max};
-
-       unless (defined($max)) {
-               defined(my $latest = $ibx->git_dir_latest(\$max)) or return;
-               $self->{epoch_max} = $max;
-       }
+       my $max = $self->{epoch_max} //= $ibx->max_git_epoch // return;
 
        foreach my $i (0..$max) {
                my $git_dir = "$pfx/$i.git";
@@ -884,7 +876,7 @@ sub reindex_checkpoint ($$) {
        my $mm_tmp = $sync->{mm_tmp};
        $mm_tmp->atfork_prepare if $mm_tmp;
        die 'BUG: {im} during reindex' if $self->{im};
-       if ($self->{ibx_map}) {
+       if ($self->{ibx_map} && !$sync->{checkpoint_unlocks}) {
                checkpoint($self, 1); # no need to release lock on pure index
        } else {
                $self->done; # release lock
@@ -896,6 +888,9 @@ sub reindex_checkpoint ($$) {
 
        # allow -watch or -mda to write...
        $self->idx_init($sync->{-opt}); # reacquire lock
+       if (my $intvl = $sync->{check_intvl}) { # eidx
+               $sync->{next_check} = PublicInbox::DS::now() + $intvl;
+       }
        $mm_tmp->atfork_parent if $mm_tmp;
 }
 
@@ -1096,8 +1091,9 @@ sub sync_prepare ($$) {
        if ($sync->{max_size} = $sync->{-opt}->{max_size}) {
                $sync->{index_oid} = $self->can('index_oid');
        }
+       my $git_pfx = "$sync->{ibx}->{inboxdir}/git";
        for (my $i = $sync->{epoch_max}; $i >= 0; $i--) {
-               my $git_dir = $sync->{ibx}->git_dir_n($i);
+               my $git_dir = "$git_pfx/$i.git";
                -d $git_dir or next; # missing epochs are fine
                my $git = PublicInbox::Git->new($git_dir);
                my $unit = { git => $git, epoch => $i };