]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/Import.pm
import: only pass Inbox object to SearchIdx->new
[public-inbox.git] / lib / PublicInbox / Import.pm
index 137b2b7800c403c188db050f0dd1df3a5583b28a..cb25215d15c39665a9b61895ebed8f98618eba77 100644 (file)
@@ -179,9 +179,9 @@ sub _update_git_info ($$) {
                run_die([@cmd, qw(read-tree -m -v -i), $self->{ref}], $env);
        }
        run_die([@cmd, 'update-server-info'], undef);
-       ($self->{path_type} eq '2/38') and eval {
+       my $ibx = $self->{-inbox};
+       ($ibx && $self->{path_type} eq '2/38') and eval {
                require PublicInbox::SearchIdx;
-               my $ibx = $self->{-inbox} || $git_dir;
                my $s = PublicInbox::SearchIdx->new($ibx);
                $s->index_sync({ ref => $self->{ref} });
        };
@@ -394,16 +394,16 @@ sub add {
        }
 
        my $blob = $self->{mark}++;
-       my $str = $mime->as_string;
-       my $n = length($str);
+       my $raw_email = $mime->{-public_inbox_raw} // $mime->as_string;
+       my $n = length($raw_email);
        $self->{bytes_added} += $n;
        print $w "blob\nmark :$blob\ndata ", $n, "\n" or wfail;
-       print $w $str, "\n" or wfail;
+       print $w $raw_email, "\n" or wfail;
 
        # v2: we need this for Xapian
        if ($self->{want_object_info}) {
                my $oid = $self->get_mark(":$blob");
-               $self->{last_object} = [ $oid, $n, \$str ];
+               $self->{last_object} = [ $oid, $n, \$raw_email ];
        }
        my $ref = $self->{ref};
        my $commit = $self->{mark}++;