$$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
$eml //= PublicInbox::Eml->new($bref);
return if $dedupe && $dedupe->is_dup($eml, $smsg);
$lei->{v2w}->ipc_do('add', $eml); # V2Writable->add
+ ++$lei->{-nr_write};
}
}
} 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");
$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') {
($lei->{opt}->{save} ? 'LeiSavedSearch' : 'LeiDedupe');
eval "require $dd_cls";
die "$dd_cls: $@" if $@;
- $dd_cls->new($lei);
+ my $dd = $dd_cls->new($lei);
+ $lei->{lss} //= $dd if $dd && $dd->can('cfg_set');
+ $dd;
};
$self;
}
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');
}
$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;