From 6fd748af8d4792d8cb857c3d2ec132ec3cca9bb8 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 3 Mar 2021 13:48:56 +0000 Subject: lei: use maildir_each_eml in more places This saves us some code and redundant callsites for eml_from_path. We'll change maildir_each_eml to include the filename to facilitate an upcoming change to "lei q" without --augment --- lib/PublicInbox/LeiToMail.pm | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) (limited to 'lib/PublicInbox/LeiToMail.pm') diff --git a/lib/PublicInbox/LeiToMail.pm b/lib/PublicInbox/LeiToMail.pm index de640657..31b8aba8 100644 --- a/lib/PublicInbox/LeiToMail.pm +++ b/lib/PublicInbox/LeiToMail.pm @@ -19,7 +19,6 @@ use IO::Handle; # ->autoflush use Fcntl qw(SEEK_SET SEEK_END O_CREAT O_EXCL O_WRONLY); use Errno qw(EEXIST ESPIPE ENOENT EPIPE); use Digest::SHA qw(sha256_hex); -my ($maildir_each_file); # struggles with short-lived repos, Gcf2Client makes little sense with lei; # but we may use in-process libgit2 in the future. @@ -268,8 +267,8 @@ sub _mbox_write_cb ($$) { } } -sub _augment_file { # maildir_each_file cb - my ($f, $lei, $mod, $shard) = @_; +sub _augment_file { # maildir_each_eml cb + my ($f, undef, $eml, $lei, $mod, $shard) = @_; if ($mod) { # can't get dirent.d_ino w/ pure Perl, so we extract the OID # if it looks like one: @@ -278,7 +277,6 @@ sub _augment_file { # maildir_each_file cb my $recno = hex(substr($hex, 0, 8)); return if ($recno % $mod) != $shard; } - my $eml = PublicInbox::InboxWritable::eml_from_path($f) or return; _augment($eml, $lei); } @@ -375,12 +373,7 @@ sub new { my $dst = $lei->{ovv}->{dst}; my $self = bless {}, $cls; if ($fmt eq 'maildir') { - $maildir_each_file //= do { - require PublicInbox::MdirReader; - PublicInbox::MdirReader->can('maildir_each_file'); - }; - $lei->{opt}->{augment} and - require PublicInbox::InboxWritable; # eml_from_path + require PublicInbox::MdirReader; $self->{base_type} = 'maildir'; -e $dst && !-d _ and die "$dst exists and is not a directory\n"; @@ -430,12 +423,13 @@ sub _do_augment_maildir { my $dedupe = $lei->{dedupe}; if ($dedupe && $dedupe->prepare_dedupe) { my ($mod, $shard) = @{$self->{shard_info} // []}; - $maildir_each_file->($dst, \&_augment_file, + PublicInbox::MdirReader::maildir_each_eml($dst, + \&_augment_file, $lei, $mod, $shard); $dedupe->pause_dedupe; } } else { # clobber existing Maildir - $maildir_each_file->($dst, \&_unlink); + PublicInbox::MdirReader::maildir_each_file($dst, \&_unlink); } } -- cgit v1.2.3-24-ge0c7