1 # Copyright (C) 2021 all contributors <meta@public-inbox.org>
2 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
4 # pretend to do PublicInbox::Import::add for "lei index"
5 package PublicInbox::FakeImport;
8 use PublicInbox::ContentHash qw(git_sha);
9 use PublicInbox::Import;
11 sub new { bless { bytes_added => 0 }, __PACKAGE__ }
14 my ($self, $eml, $check_cb, $smsg) = @_;
15 PublicInbox::Import::drop_unwanted_headers($eml);
16 $smsg->populate($eml);
17 my $raw = $eml->as_string;
18 $smsg->{blob} = git_sha(1, \$raw)->hexdigest;
19 $smsg->set_bytes($raw, length($raw));
20 if (my $oidx = delete $smsg->{-oidx}) { # used by LeiStore
21 $oidx->vivify_xvmd($smsg) or return;