use v5.10.1;
use PublicInbox::DS;
use PublicInbox::Spawn qw(which popen_rd);
+use PublicInbox::InboxWritable qw(eml_from_path);
# JMAP RFC 8621 4.1.1
# https://www.iana.org/assignments/imap-jmap-keywords/imap-jmap-keywords.xhtml
$ifmt = lc($1);
} elsif ($input =~ /\.(?:patch|eml)\z/i) {
$ifmt = 'eml';
+ } elsif (-f $input && $input =~ m{\A(?:.+)/(?:new|cur)/([^/]+)\z}) {
+ my $bn = $1;
+ my $fl = PublicInbox::MdirReader::maildir_basename_flags($bn);
+ return if index($fl, 'T') >= 0;
+ return $self->pmdir_cb($input, $fl) if $self->can('pmdir_cb');
+ my $eml = eml_from_path($input) or return
+ $lei->qerr("# $input not readable");
+ my $kw = PublicInbox::MdirReader::flags2kw($fl);
+ $self->can('input_maildir_cb')->($input, $kw, $eml, $self);
+ return;
}
my $devfd = $lei->path_to_fd($input) // return;
if ($devfd >= 0) {
if ($input =~ m!\A(?:imaps?|nntps?|s?news)://!i) {
require PublicInbox::NetReader;
$net //= PublicInbox::NetReader->new;
- $net->add_url($input);
+ $net->add_url($input, $self->{-ls_ok});
push @{$sync->{ok}}, $input if $sync;
} elsif ($input_path =~ m!\Ahttps?://!i) { # mboxrd.gz
# TODO: how would we detect r/w JMAP?
$sync and $input = 'maildir:'.
$lei->abs_path($input_path);
push @md, $input;
+ } elsif ($self->{missing_ok} && !-e _) {
+ # for "lei rm-watch" on missing Maildir
+ $sync and $input = 'maildir:'.
+ $lei->abs_path($input_path);
} else {
return $lei->fail("Unable to handle $input");
}
lc($in_fmt//'eml') eq 'eml' or return $lei->fail(<<"");
$input is `eml', not --in-format=$in_fmt
- require PublicInbox::Eml;
push @{$sync->{no}}, $input if $sync;
+ } elsif (-f $input && $input =~ m{\A(.+)/(new|cur)/([^/]+)\z}) {
+ # single file in a Maildir
+ my ($mdir, $nc, $bn) = ($1, $2, $3);
+ my $other = $mdir . ($nc eq 'new' ? '/cur' : '/new');
+ return $lei->fail(<<EOM) if !-d $other;
+No `$other' directory for `$input'
+EOM
+ lc($in_fmt//'eml') eq 'eml' or return $lei->fail(<<"");
+$input is `eml', not --in-format=$in_fmt
+
+ if ($sync) {
+ $input = $lei->abs_path($mdir) . "/$nc/$bn";
+ push @{$sync->{ok}}, $input;
+ }
+ require PublicInbox::MdirReader;
} else {
my $devfd = $lei->path_to_fd($input) // return;
if ($devfd >= 0 || -f $input || -p _) {
push @f, $input;
} elsif (-d "$input/new" && -d "$input/cur") {
if ($sync) {
- $input = $lei->abs_path($input);
+ $input = 'maildir:'.
+ $lei->abs_path($input);
push @{$sync->{ok}}, $input;
}
push @md, $input;
+ } elsif ($self->{missing_ok} && !-e $input) {
+ # for lei rm-watch
+ $sync and $input = 'maildir:'.
+ $lei->abs_path($input);
} else {
return $lei->fail("Unable to handle $input")
}
# like Getopt::Long, but for +kw:FOO and -kw:FOO to prepare
# for update_xvmd -> update_vmd
+# returns something like { "+L" => [ @Labels ], ... }
sub vmd_mod_extract {
my $argv = $_[-1];
my $vmd_mod = {};