about summary refs log tree commit homepage
path: root/lib/PublicInbox/SearchIdx.pm
diff options
context:
space:
mode:
authorEric Wong (Contractor, The Linux Foundation) <e@80x24.org>2018-03-19 08:14:39 +0000
committerEric Wong (Contractor, The Linux Foundation) <e@80x24.org>2018-03-19 08:16:34 +0000
commiteb48e7d6675babdda9a36be1a490c29a2ccddbdc (patch)
treeeaa6056df3a6eabe9952b7265c9770de6b3575f1 /lib/PublicInbox/SearchIdx.pm
parentb20b8747256433b0b7b4d1ed5c415d2101044dda (diff)
downloadpublic-inbox-eb48e7d6675babdda9a36be1a490c29a2ccddbdc.tar.gz
We need to hide removals from anybody hitting the search engine.
Diffstat (limited to 'lib/PublicInbox/SearchIdx.pm')
-rw-r--r--lib/PublicInbox/SearchIdx.pm32
1 files changed, 32 insertions, 0 deletions
diff --git a/lib/PublicInbox/SearchIdx.pm b/lib/PublicInbox/SearchIdx.pm
index ccec0181..ae2544da 100644
--- a/lib/PublicInbox/SearchIdx.pm
+++ b/lib/PublicInbox/SearchIdx.pm
@@ -440,6 +440,31 @@ sub remove_message {
         }
 }
 
+# MID is a hint in V2
+sub remove_by_oid {
+        my ($self, $oid, $mid) = @_;
+        my $db = $self->{xdb};
+
+        # XXX careful, we cannot use batch_do here since we conditionally
+        # delete documents based on other factors, so we cannot call
+        # find_doc_ids twice.
+        my ($head, $tail) = $self->find_doc_ids('Q' . $mid);
+        return if $head == $tail;
+
+        # there is only ONE element in @delete unless we
+        # have bugs in our v2writable deduplication check
+        my @delete;
+        for (; $head != $tail; $head->inc) {
+                my $docid = $head->get_docid;
+                my $doc = $db->get_document($docid);
+                my $smsg = PublicInbox::SearchMsg->wrap($doc, $mid);
+                $smsg->load_expand;
+                push(@delete, $docid) if $smsg->{blob} eq $oid;
+        }
+        $db->delete_document($_) foreach @delete;
+        scalar(@delete);
+}
+
 sub term_generator { # write-only
         my ($self) = @_;
 
@@ -896,4 +921,11 @@ sub remote_close {
         $? == 0 or die ref($self)." pid:$pid exited with: $?";
 }
 
+# triggers remove_by_oid in partition or skeleton
+sub remote_remove {
+        my ($self, $oid, $mid) = @_;
+        print { $self->{w} } "D $oid $mid\n" or
+                        die "failed to write remove $!";
+}
+
 1;