about summary refs log tree commit homepage
path: root/lib/PublicInbox
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2021-10-23 18:20:40 -0600
committerEric Wong <e@80x24.org>2021-10-24 02:20:33 +0000
commitf59ac79a64759396ce484616393cdad18d431a57 (patch)
tree397b6741fb77b9ce6250ae6b1dd78e477c928047 /lib/PublicInbox
parentcb04d2ddfd53c36eaf1a49cadb8158ae76622683 (diff)
downloadpublic-inbox-f59ac79a64759396ce484616393cdad18d431a57.tar.gz
Since we want to store IMAP flags asynchronously and not wait
for results, we can't check for IMAP errors this way and end up
wasting bandwidth on public-inbox-imapd.  Now, we just check
PERMANENTFLAGS up front to ensure a folder can handle IMAP flag
storage before proceeding.
Diffstat (limited to 'lib/PublicInbox')
-rw-r--r--lib/PublicInbox/LeiExportKw.pm12
-rw-r--r--lib/PublicInbox/NetWriter.pm9
2 files changed, 20 insertions, 1 deletions
diff --git a/lib/PublicInbox/LeiExportKw.pm b/lib/PublicInbox/LeiExportKw.pm
index 756d0e9c..0ecfb782 100644
--- a/lib/PublicInbox/LeiExportKw.pm
+++ b/lib/PublicInbox/LeiExportKw.pm
@@ -67,7 +67,17 @@ sub input_path_url {
                 $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;
diff --git a/lib/PublicInbox/NetWriter.pm b/lib/PublicInbox/NetWriter.pm
index 629a752a..4a1f34f6 100644
--- a/lib/PublicInbox/NetWriter.pm
+++ b/lib/PublicInbox/NetWriter.pm
@@ -56,4 +56,13 @@ sub imap_set_kw {
         $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;