diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2018-08-01 11:43:38 -0500 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2018-08-02 02:18:13 +0000 |
commit | ad2080deb8102a75d2f26b448267c209bea4b4e2 (patch) | |
tree | 821efcfb48fa0eb70027959d0c9afbfef9e519c2 | |
parent | 075d15d10333ea9127170b8c7635e4286777c005 (diff) | |
download | public-inbox-ad2080deb8102a75d2f26b448267c209bea4b4e2.tar.gz |
When walking messages newest to oldest, assigning the larger numbers before smaller numbers ensures older messages get smaller numbers. This leads to the possibility of a msgmap that can be regenerated when needed. Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
-rw-r--r-- | lib/PublicInbox/SearchIdx.pm | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/lib/PublicInbox/SearchIdx.pm b/lib/PublicInbox/SearchIdx.pm index 1d259a86..ac821ac0 100644 --- a/lib/PublicInbox/SearchIdx.pm +++ b/lib/PublicInbox/SearchIdx.pm @@ -619,23 +619,28 @@ sub _git_log { my ($self, $range) = @_; my $git = $self->{git}; + # Count the new files so they can be added newest to oldest + # and still have numbers increasing from oldest to newest + my $fcount = 0; + # can't use 'rev-list --count' if we use --diff-filter + my $fh = $git->popen(qw(log --pretty=tformat:%h + --no-notes --no-color --no-renames + --diff-filter=AM), $range); + ++$fcount while <$fh>; + my (undef, $max) = $self->{mm}->minmax; + if (index($range, '..') < 0) { - my $regen_max = 0; - # can't use 'rev-list --count' if we use --diff-filter - my $fh = $git->popen(qw(log --pretty=tformat:%h - --no-notes --no-color --no-renames - --diff-filter=AM), $range); - ++$regen_max while <$fh>; - my (undef, $max) = $self->{mm}->minmax; - - if ($max && $max == $regen_max) { + if ($max && $max == $fcount) { # fix up old bugs in full indexes which caused messages to # not appear in Msgmap $self->{regen_up} = $max; } else { # normal regen is for for fresh data - $self->{regen_down} = $regen_max; + $self->{regen_down} = $fcount; } + } else { + # Give oldest messages the smallest numbers + $self->{regen_down} = $max + $fcount; } $git->popen(qw/log --no-notes --no-color --no-renames |