From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.0 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 1EB981FAE2 for ; Fri, 30 Mar 2018 01:20:49 +0000 (UTC) From: "Eric Wong (Contractor, The Linux Foundation)" To: meta@public-inbox.org Subject: [PATCH 2/9] v2writable: allow gaps in git partitions Date: Fri, 30 Mar 2018 01:20:41 +0000 Message-Id: <20180330012048.15985-3-e@80x24.org> In-Reply-To: <20180330012048.15985-1-e@80x24.org> References: <20180330012048.15985-1-e@80x24.org> List-Id: Somebody may only care about the most recent history, so allow -init and -index to operate quietly on missing partitions. --- lib/PublicInbox/V2Writable.pm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/PublicInbox/V2Writable.pm b/lib/PublicInbox/V2Writable.pm index 4e7d6de..6394d30 100644 --- a/lib/PublicInbox/V2Writable.pm +++ b/lib/PublicInbox/V2Writable.pm @@ -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); -- EW