From 8600c999da4786d2297ebbf44aa0618461c2f3cf Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 8 Feb 2021 05:06:51 -0100 Subject: lei import: support Maildirs It seems to be working trivially, though I'm probably going to split out Maildir reading into a separate package rather than using LeiToMail. --- lib/PublicInbox/LeiToMail.pm | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'lib/PublicInbox/LeiToMail.pm') diff --git a/lib/PublicInbox/LeiToMail.pm b/lib/PublicInbox/LeiToMail.pm index 3f65e9e9..4c5a5685 100644 --- a/lib/PublicInbox/LeiToMail.pm +++ b/lib/PublicInbox/LeiToMail.pm @@ -266,8 +266,9 @@ sub _mbox_write_cb ($$) { } } -sub _maildir_each_file ($$;@) { +sub maildir_each_file ($$;@) { my ($dir, $cb, @arg) = @_; + $dir .= '/' unless substr($dir, -1) eq '/'; for my $d (qw(new/ cur/)) { my $pfx = $dir.$d; opendir my $dh, $pfx or next; @@ -277,13 +278,13 @@ sub _maildir_each_file ($$;@) { } } -sub _augment_file { # _maildir_each_file cb +sub _augment_file { # maildir_each_file cb my ($f, $lei) = @_; my $eml = PublicInbox::InboxWritable::eml_from_path($f) or return; _augment($eml, $lei); } -# _maildir_each_file callback, \&CORE::unlink doesn't work with it +# maildir_each_file callback, \&CORE::unlink doesn't work with it sub _unlink { unlink($_[0]) } sub _rand () { @@ -379,11 +380,11 @@ sub _do_augment_maildir { my $dedupe = $lei->{dedupe}; if ($dedupe && $dedupe->prepare_dedupe) { require PublicInbox::InboxWritable; # eml_from_path - _maildir_each_file($dst, \&_augment_file, $lei); + maildir_each_file($dst, \&_augment_file, $lei); $dedupe->pause_dedupe; } } else { # clobber existing Maildir - _maildir_each_file($dst, \&_unlink); + maildir_each_file($dst, \&_unlink); } } -- cgit v1.2.3-24-ge0c7