X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=lib%2FPublicInbox%2FLeiToMail.pm;h=d3253d9b01139bf6a2ea7b29cd0a5619485d2f41;hb=47d4e53734820b4e;hp=be6e178fe2c3019575afa815ba4faeac3a61c80f;hpb=d99020ac3612308d04e3760bd780417218748168;p=public-inbox.git diff --git a/lib/PublicInbox/LeiToMail.pm b/lib/PublicInbox/LeiToMail.pm index be6e178f..d3253d9b 100644 --- a/lib/PublicInbox/LeiToMail.pm +++ b/lib/PublicInbox/LeiToMail.pm @@ -109,32 +109,25 @@ sub _mboxcl_common ($$$) { $$buf .= 'Content-Length: '.length($$bdy).$crlf. 'Lines: '.$lines.$crlf.$crlf; substr($$bdy, 0, 0, $$buf); # prepend header - $_[0] = $bdy; + $$bdy .= $crlf; + $bdy; } # mboxcl still escapes "From " lines sub eml2mboxcl { my ($eml, $smsg) = @_; my $buf = _mbox_hdr_buf($eml, 'mboxcl', $smsg); - my $crlf = $eml->{crlf}; - if (my $bdy = delete $eml->{bdy}) { - $$bdy =~ s/^From />From /gm; - _mboxcl_common($buf, $bdy, $crlf); - } - $$buf .= $crlf; - $buf; + my $bdy = delete($eml->{bdy}) // \(my $empty = ''); + $$bdy =~ s/^From />From /gm; + _mboxcl_common($buf, $bdy, $eml->{crlf}); } # mboxcl2 has no "From " escaping sub eml2mboxcl2 { my ($eml, $smsg) = @_; my $buf = _mbox_hdr_buf($eml, 'mboxcl2', $smsg); - my $crlf = $eml->{crlf}; - if (my $bdy = delete $eml->{bdy}) { - _mboxcl_common($buf, $bdy, $crlf); - } - $$buf .= $crlf; - $buf; + my $bdy = delete($eml->{bdy}) // \(my $empty = ''); + _mboxcl_common($buf, $bdy, $eml->{crlf}); } sub git_to_mail { # git->cat_async callback @@ -368,6 +361,7 @@ sub _v2_write_cb ($$) { $eml //= PublicInbox::Eml->new($bref); return if $dedupe && $dedupe->is_dup($eml, $smsg); $lei->{v2w}->ipc_do('add', $eml); # V2Writable->add + ++$lei->{-nr_write}; } } @@ -403,10 +397,11 @@ sub new { } elsif ($fmt =~ /\Aimaps?\z/) { require PublicInbox::NetWriter; require PublicInbox::URIimap; - my $net = PublicInbox::NetWriter->new; + # {net} may exist from "lei up" for auth + my $net = $lei->{net} // PublicInbox::NetWriter->new; $net->{quiet} = $lei->{opt}->{quiet}; my $uri = PublicInbox::URIimap->new($dst)->canonical; - $net->add_url($uri); + $net->add_url($$uri); my $err = $net->errors($lei); return $lei->fail($err) if $err; $uri->mailbox or return $lei->fail("No mailbox: $dst"); @@ -415,9 +410,9 @@ sub new { $lei->{net} = $net; $self->{base_type} = 'imap'; $lei->{opt}->{save} //= \1 if $lei->{cmd} eq 'q'; - } elsif ($fmt eq 'text') { + } elsif ($fmt eq 'text' || $fmt eq 'reply') { require PublicInbox::LeiViewText; - $lei->{lvt} = PublicInbox::LeiViewText->new($lei); + $lei->{lvt} = PublicInbox::LeiViewText->new($lei, $fmt); $self->{base_type} = 'text'; @conflict = qw(mua save); } elsif ($fmt eq 'v2') { @@ -463,8 +458,10 @@ sub _pre_augment_maildir { sub clobber_dst_prepare ($;$) { my ($lei, $f) = @_; - my $wait = (defined($f) && $lei->{sto}) ? - $lei->{sto}->ipc_do('lms_forget_folders', $f) : undef; + if (my $lms = defined($f) ? $lei->lms : undef) { + $lms->lms_write_prepare; + $lms->forget_folders($f); + } my $dedupe = $lei->{dedupe} or return; $dedupe->reset_dedupe if $dedupe->can('reset_dedupe'); } @@ -790,6 +787,4 @@ sub net_merge_all_done { $self->wq_close(1); } -no warnings 'once'; # the following works even when LeiAuth is lazy-loaded -*net_merge_all = \&PublicInbox::LeiAuth::net_merge_all; 1;