]> Sergey Matveev's repositories - public-inbox.git/commitdiff
searchidx: remove v1-only msg_mime sub
authorEric Wong <e@yhbt.net>
Sat, 1 Aug 2020 08:12:26 +0000 (08:12 +0000)
committerEric Wong <e@yhbt.net>
Sun, 2 Aug 2020 08:26:19 +0000 (08:26 +0000)
We can rely on the newer mids() sub directly and use faster
numeric comparisons for Msgmap unindexing in v1.

lib/PublicInbox/MID.pm
lib/PublicInbox/SearchIdx.pm
t/search.t

index 685306dbf37658356b9cb7572c1ab04bbba46d50..e9a3b0c094e52b3fce1d330374d03b6bd7520235 100644 (file)
@@ -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;
index 080aca7cb7b79cb05509ef2a1916d0f65430ff5b..feb00de22e062a86c7042b2f5234496a9b606c61 100644 (file)
@@ -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
index a75d944c32e9a1bf7a1e448072ba88d9772cc2ed..299f57c85ee0c505c545310f3ad9afd32bfa42a5 100644 (file)
@@ -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: {