# pretend to do PublicInbox::Import::add for "lei index"
package PublicInbox::FakeImport;
use strict;
+use v5.10.1;
use PublicInbox::ContentHash qw(git_sha);
+use PublicInbox::Import;
sub new { bless { bytes_added => 0 }, __PACKAGE__ }
sub add {
my ($self, $eml, $check_cb, $smsg) = @_;
+ PublicInbox::Import::drop_unwanted_headers($eml);
$smsg->populate($eml);
my $raw = $eml->as_string;
$smsg->{blob} = git_sha(1, \$raw)->hexdigest;
}
}
+sub git_blob_id {
+ my ($lei, $eml) = @_;
+ ($lei->{sto} // _lei_store($lei, 1))->git_blob_id($eml);
+}
+
1;
my @only = @{$opt->{only} // []};
# --local is enabled by default unless --only is used
# we'll allow "--only $LOCATION --local"
- my $sto = $self->_lei_store(1); # FIXME: should not create
+ my $sto = $self->_lei_store(1);
$self->{lse} = $sto->search;
if ($opt->{'local'} //= scalar(@only) ? 0 : 1) {
$lxs->prepare_external($self->{lse});
$smsg = $res if ref($res) eq ref($smsg);
}
$smsg->{blob} //= $xoids ? (keys(%$xoids))[0]
- : git_sha(1, $eml)->hexdigest;
+ : $lei->git_blob_id($eml);
$smsg->populate($eml);
$smsg->{mid} //= '(none)';
push @{$self->{smsg}}, $smsg;
use PublicInbox::Import;
use PublicInbox::InboxWritable qw(eml_from_path);
use PublicInbox::V2Writable;
-use PublicInbox::ContentHash qw(content_hash);
+use PublicInbox::ContentHash qw(content_hash git_sha);
use PublicInbox::MID qw(mids);
use PublicInbox::LeiSearch;
use PublicInbox::MDA;
$lei->{sto} = $self;
}
+# TODO: support SHA-256
+sub git_blob_id { # called via LEI->git_blob_id
+ my ($self, $eml) = @_;
+ $eml->header_set($_) for @PublicInbox::Import::UNWANTED_HEADERS;
+ git_sha(1, $eml)->hexdigest;
+}
+
1;
$smsg->{kw} = []; # short-circuit xsmsg_vmd
}
}
- $smsg->{blob} //= $xoids ? (keys(%$xoids))[0]
- : git_sha(1, $eml)->hexdigest;
+ $smsg->{blob} //= $xoids ? (keys(%$xoids))[0] : $lei->git_blob_id($eml);
_smsg_fill($smsg, $eml);
wait_startq($lei);
if ($lei->{-progress}) {