$self->{lms}->each_src($input, \&export_kw_md, $self, $mdir);
} elsif ($input =~ m!\Aimaps?://!i) {
my $uri = PublicInbox::URIimap->new($input);
- if (my $mic = $self->{nwr}->mic_for_folder($uri)) {
+ my $mic = $self->{nwr}->mic_for_folder($uri);
+ if ($mic && !$self->{nwr}->can_store_flags($mic)) {
+ my $m = "$input does not support PERMANENTFLAGS";
+ if (defined $self->{lei}->{opt}->{all}) {
+ $self->{lei}->qerr("# $m");
+ } else { # set error code if user explicitly requested
+ $self->{lei}->child_error(0, "E: $m");
+ }
+ return;
+ }
+ if ($mic) {
$self->{lms}->each_src($$uri, \&export_kw_imap,
$self, $mic);
$mic->expunge;
$mic; # caller must ->expunge
}
+sub can_store_flags {
+ my ($self, $mic) = @_;
+ for ($mic->Results) {
+ /^\* OK \[PERMANENTFLAGS \(([^\)]*)\)\].*/ and
+ return $self->can('perm_fl_ok')->($1);
+ }
+ undef;
+}
+
1;
use strict; use v5.10.1; use PublicInbox::TestCommon;
use File::Copy qw(cp);
use File::Path qw(make_path);
-require_mods(qw(lei -imapd Mail::IMAPClient));
+require_mods(qw(lei)); # see lei-import-imap.t for IMAP tests
my ($tmpdir, $for_destroy) = tmpdir;
my $expect = eml_load('t/data/0001.patch');
my $do_export_kw = 1;
is(scalar(@$out), 2, 'got JSON') or diag explain($out);
lei_ok qw(lcat), $url_orig;
is($lei_out, $orig, 'lcat w/o UID works');
+
+ ok(!lei(qw(export-kw), $url_orig), 'export-kw fails on read-only IMAP');
+ like($lei_err, qr/does not support/, 'error noted in failure');
});
done_testing;