]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/SearchIdxShard.pm
searchidxshard: clear $msgref buffer properly
[public-inbox.git] / lib / PublicInbox / SearchIdxShard.pm
index cb79f3dc9dfcb26499232a61beb0ffa778ec0a07..75521b43a4087badcc5daa2bccc5adcd9323956d 100644 (file)
@@ -16,7 +16,7 @@ sub new {
        my $self = $class->SUPER::new($ibx, 1, $shard);
        # create the DB before forking:
        $self->idx_acquire;
-       $self->set_indexlevel;
+       $self->set_metadata_once;
        $self->idx_release;
        $self->spawn_worker($v2w, $shard) if $v2w->{parallel};
        $self;
@@ -89,16 +89,20 @@ sub shard_worker_loop ($$$$$) {
 
 # called by V2Writable
 sub index_raw {
-       my ($self, $msgref, $mime, $smsg) = @_;
+       my ($self, $msgref, $eml, $smsg) = @_;
        if (my $w = $self->{w}) {
                # mid must be last, it can contain spaces (but not LF)
                print $w join(' ', @$smsg{qw(raw_bytes bytes
                                                num blob ds ts mid)}),
                        "\n", $$msgref or die "failed to write shard $!\n";
        } else {
-               $$msgref = undef;
+               if ($eml) {
+                       undef $$msgref;
+               } else { # --xapian-only + --sequential-shard:
+                       $eml = PublicInbox::Eml->new($msgref);
+               }
                $self->begin_txn_lazy;
-               $self->add_message($mime, $smsg);
+               $self->add_message($eml, $smsg);
        }
 }