From fb4bfa102bfa702f13948ac689e54bac9d0084e0 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 1 Aug 2020 08:12:26 +0000 Subject: searchidx: remove v1-only msg_mime sub We can rely on the newer mids() sub directly and use faster numeric comparisons for Msgmap unindexing in v1. --- lib/PublicInbox/MID.pm | 5 +---- lib/PublicInbox/SearchIdx.pm | 16 +++++++--------- t/search.t | 1 + 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/lib/PublicInbox/MID.pm b/lib/PublicInbox/MID.pm index 685306db..e9a3b0c0 100644 --- a/lib/PublicInbox/MID.pm +++ b/lib/PublicInbox/MID.pm @@ -6,7 +6,7 @@ package PublicInbox::MID; use strict; use warnings; use base qw/Exporter/; -our @EXPORT_OK = qw(mid_clean id_compress mid2path mid_mime mid_escape MID_ESC +our @EXPORT_OK = qw(mid_clean id_compress mid2path mid_escape MID_ESC mids references mids_for_index $MID_EXTRACT); use URI::Escape qw(uri_escape_utf8); use Digest::SHA qw/sha1_hex/; @@ -53,9 +53,6 @@ sub mid2path { "$x2/$x38"; } -# Only for v1 code paths: -sub mid_mime ($) { mids($_[0]->header_obj)->[0] } - # only intended for Message-ID and X-Alt-Message-ID sub extract_mids { my @mids; diff --git a/lib/PublicInbox/SearchIdx.pm b/lib/PublicInbox/SearchIdx.pm index 080aca7c..feb00de2 100644 --- a/lib/PublicInbox/SearchIdx.pm +++ b/lib/PublicInbox/SearchIdx.pm @@ -12,7 +12,7 @@ use v5.10.1; use parent qw(PublicInbox::Search PublicInbox::Lock Exporter); use PublicInbox::Eml; use PublicInbox::InboxWritable; -use PublicInbox::MID qw(mid_mime mids_for_index mids); +use PublicInbox::MID qw(mids_for_index mids); use PublicInbox::MsgIter; use PublicInbox::IdxStack; use Carp qw(croak); @@ -492,6 +492,11 @@ sub unindex_eml { while (my ($num, $nr) = each %tmp) { warn "BUG: $num appears >1 times ($nr) for $oid\n" if $nr != 1; } + if ($nr) { + $self->{mm}->num_delete($_) for (keys %tmp); + } else { # just in case msgmap and over.sqlite3 become desynched: + $self->{mm}->mid_delete($mids->[0]); + } xdb_remove($self, $oid, keys %tmp) if need_xapian($self); } @@ -512,11 +517,6 @@ sub index_mm { } } -sub unindex_mm { - my ($self, $mime) = @_; - $self->{mm}->mid_delete(mid_mime($mime)); -} - # returns the number of bytes to add if given a non-CRLF arg sub crlf_adjust ($) { if (index($_[0], "\r\n") < 0) { @@ -544,9 +544,7 @@ sub index_both { # git->cat_async callback sub unindex_both { # git->cat_async callback my ($bref, $oid, $type, $size, $self) = @_; - my $eml = PublicInbox::Eml->new($bref); - unindex_eml($self, $oid, $eml); - unindex_mm($self, $eml); + unindex_eml($self, $oid, PublicInbox::Eml->new($bref)); } # called by public-inbox-index diff --git a/t/search.t b/t/search.t index a75d944c..299f57c8 100644 --- a/t/search.t +++ b/t/search.t @@ -420,6 +420,7 @@ $ibx->with_umask(sub { $art = $ro->{over_ro}->next_by_mid($mid, \$id, \$prev); ok($art, 'article exists in OVER DB'); } + $rw->_msgmap_init; $rw->unindex_eml($oid, $amsg); $rw->commit_txn_lazy; SKIP: { -- cgit v1.2.3-24-ge0c7