]> Sergey Matveev's repositories - public-inbox.git/commitdiff
v2writable: allow gaps in git partitions
authorEric Wong (Contractor, The Linux Foundation) <e@80x24.org>
Fri, 30 Mar 2018 01:20:41 +0000 (01:20 +0000)
committerEric Wong (Contractor, The Linux Foundation) <e@80x24.org>
Fri, 30 Mar 2018 01:21:00 +0000 (01:21 +0000)
Somebody may only care about the most recent history,
so allow -init and -index to operate quietly on missing
partitions.

lib/PublicInbox/V2Writable.pm

index 4e7d6de1d132717712cdf5916a3b6d3268367554..6394d300fa2eb8e8d6f0287eaa7935c9233194f2 100644 (file)
@@ -67,7 +67,9 @@ sub init_inbox {
        my ($self, $parallel) = @_;
        $self->{parallel} = $parallel;
        $self->idx_init;
-       $self->git_init(0);
+       my $max_git = -1;
+       git_dir_latest($self, \$max_git);
+       $self->git_init($max_git >= 0 ? $max_git : 0);
        $self->done;
 }
 
@@ -621,6 +623,7 @@ sub reindex {
                for (my $cur = $max_git; $cur >= 0; $cur--) {
                        die "already reindexing!\n" if $self->{reindex_pipe};
                        my $git = PublicInbox::Git->new("$pfx/$cur.git");
+                       -d $git->{git_dir} or next; # missing parts are fine
                        chomp($tip = $git->qx('rev-parse', $head)) unless $tip;
                        my $h = $cur == $max_git ? $tip : $head;
                        my @count = ('rev-list', '--count', $h, '--', 'm');
@@ -642,6 +645,7 @@ sub reindex {
                die "already reindexing!\n" if delete $self->{reindex_pipe};
                my $cmt;
                my $git_dir = "$pfx/$cur.git";
+               -d $git_dir or next; # missing parts are fine
                my $git = PublicInbox::Git->new($git_dir);
                my $h = $cur == $max_git ? $tip : $head;
                my $fh = $self->{reindex_pipe} = $git->popen(@cmd, $h);