require PublicInbox::Msgmap;
my $sidx = PublicInbox::SearchIdx->new($self, 1); # just create
$sidx->begin_txn_lazy;
- my $mm = PublicInbox::Msgmap->new($self->{inboxdir}, 1);
+ my $mm = PublicInbox::Msgmap->new_file($self, 1);
if (defined $skip_artnum) {
$mm->{dbh}->begin_work;
$mm->skip_artnum($skip_artnum);
}
}
-sub _each_maildir_fn {
- my ($fn, $im, $self) = @_;
- if ($fn =~ /:2,([A-Za-z]*)\z/) {
- my $fl = $1;
- return if $fl =~ /[DT]/; # no Drafts or Trash for public
- }
- my $eml = eml_from_path($fn) or return;
+sub _each_maildir_eml {
+ my ($fn, $kw, $eml, $im, $self) = @_;
+ return if grep(/\Adraft\z/, @$kw);
if ($self && (my $filter = $self->filter($im))) {
my $ret = $filter->scrub($eml) or return;
return if $ret == REJECT();
$im->add($eml);
}
+# XXX does anybody use this?
sub import_maildir {
my ($self, $dir) = @_;
foreach my $sub (qw(cur new tmp)) {
my $im = $self->importer(1);
my @self = $self->filter($im) ? ($self) : ();
require PublicInbox::MdirReader;
- PublicInbox::MdirReader::maildir_each_file(\&_each_maildir_fn,
- $im, @self);
+ PublicInbox::MdirReader->new->maildir_each_eml($dir,
+ \&_each_maildir_eml, $im, @self);
$im->done;
}
sub import_mbox {
my ($self, $fh, $variant) = @_;
require PublicInbox::MboxReader;
- my $cb = PublicInbox::MboxReader->can($variant) or
+ my $cb = PublicInbox::MboxReader->reads($variant) or
die "$variant not supported\n";
my $im = $self->importer(1);
$cb->(undef, $fh, \&_mbox_eml_cb, $im, $self->filter);