From 1b7e935ab1690e28d790d8db5af2714f13c258cc Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 14 May 2019 02:04:43 +0000 Subject: searchidx: fix incremental index with indexlevel=basic on v1 We were reindexing the full history every invocation of -index when Xapian was not used because we were incorrectly relying on 'last_commit' metadata stored in Xapian. Rewrite the indexing logic to be less confusing while we're at it, since we rely on `git merge-base --is-ancestor' nowadays. Furthermore, we need to handle message removals from the overview index correctly when Xapian is not in use. Co-authored-by: Eric W. Biederman --- lib/PublicInbox/OverIdx.pm | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'lib/PublicInbox/OverIdx.pm') diff --git a/lib/PublicInbox/OverIdx.pm b/lib/PublicInbox/OverIdx.pm index cc9bd7d4..bb3068dd 100644 --- a/lib/PublicInbox/OverIdx.pm +++ b/lib/PublicInbox/OverIdx.pm @@ -317,14 +317,21 @@ sub delete_articles { $self->delete_by_num($_) foreach @$nums; } +# returns number of removed messages +# $oid may be undef to match only on $mid sub remove_oid { my ($self, $oid, $mid) = @_; + my $nr = 0; $self->begin_lazy; each_by_mid($self, $mid, ['ddd'], sub { my ($smsg) = @_; - $self->delete_by_num($smsg->{num}) if $smsg->{blob} eq $oid; + if (!defined($oid) || $smsg->{blob} eq $oid) { + $self->delete_by_num($smsg->{num}); + $nr++; + } 1; }); + $nr; } sub create_tables { -- cgit v1.2.3-24-ge0c7