user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download mbox.gz: |
* [PATCH 3/4] searchidx: remove v1-only msg_mime sub
  2020-08-01  8:12  7% [PATCH 0/4] cleanup some minor annoyances Eric Wong
@ 2020-08-01  8:12  7% ` Eric Wong
  0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2020-08-01  8:12 UTC (permalink / raw)
  To: meta

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 685306dbf..e9a3b0c09 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 080aca7cb..feb00de22 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 a75d944c3..299f57c85 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: {

^ permalink raw reply related	[relevance 7%]

* [PATCH 0/4] cleanup some minor annoyances
@ 2020-08-01  8:12  7% Eric Wong
  2020-08-01  8:12  7% ` [PATCH 3/4] searchidx: remove v1-only msg_mime sub Eric Wong
  0 siblings, 1 reply; 2+ results
From: Eric Wong @ 2020-08-01  8:12 UTC (permalink / raw)
  To: meta

Just some minor stuff I noticed while tracking down -watch
failures resolved by
https://public-inbox.org/meta/20200731213618.GA19572@dcvr/

Eric Wong (4):
  inboxwritable: mime_from_path: reduce `$/' scope and returns
  inboxwritable: rename mime_from_path to eml_from_path
  searchidx: remove v1-only msg_mime sub
  remove unnecessary ->header_obj calls

 lib/PublicInbox/ContentHash.pm   | 15 +++++++-------
 lib/PublicInbox/Import.pm        | 17 +++++++---------
 lib/PublicInbox/InboxWritable.pm | 25 ++++++++++-------------
 lib/PublicInbox/MID.pm           |  5 +----
 lib/PublicInbox/OverIdx.pm       |  9 ++++----
 lib/PublicInbox/SearchIdx.pm     | 30 ++++++++++++---------------
 lib/PublicInbox/V2Writable.pm    | 35 +++++++++++++++-----------------
 lib/PublicInbox/View.pm          | 35 +++++++++++++++-----------------
 lib/PublicInbox/WatchMaildir.pm  | 10 ++++-----
 lib/PublicInbox/WwwAtomStream.pm |  9 ++++----
 script/public-inbox-edit         | 15 +++++++-------
 script/public-inbox-mda          |  2 +-
 t/search.t                       |  1 +
 13 files changed, 92 insertions(+), 116 deletions(-)

^ permalink raw reply	[relevance 7%]

Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2020-08-01  8:12  7% [PATCH 0/4] cleanup some minor annoyances Eric Wong
2020-08-01  8:12  7% ` [PATCH 3/4] searchidx: remove v1-only msg_mime sub Eric Wong

Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).