From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id E8F991FC0B for ; Fri, 3 Sep 2021 08:54:27 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 8/8] lei: fix read/write IMAP access Date: Fri, 3 Sep 2021 08:54:27 +0000 Message-Id: <20210903085427.5541-9-e@80x24.org> In-Reply-To: <20210903085427.5541-1-e@80x24.org> References: <20210903085427.5541-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: xt/net_writer-imap.t was completely broken in recent months and I completely forgot this test. net->add_url still only accepts bare scalars (and not scalar refs), so we must set that up properly. Furthermore, our changes to do FLAGS-only synchronization in lei of old messages was causing us to not handle FLAGS properly for the test. --- lib/PublicInbox/LeiToMail.pm | 2 +- lib/PublicInbox/NetReader.pm | 5 ++++- lib/PublicInbox/NetWriter.pm | 2 ++ lib/PublicInbox/Watch.pm | 2 ++ 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/PublicInbox/LeiToMail.pm b/lib/PublicInbox/LeiToMail.pm index be6e178f..6e102a1d 100644 --- a/lib/PublicInbox/LeiToMail.pm +++ b/lib/PublicInbox/LeiToMail.pm @@ -406,7 +406,7 @@ sub new { my $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"); diff --git a/lib/PublicInbox/NetReader.pm b/lib/PublicInbox/NetReader.pm index 23445e7a..c050c60f 100644 --- a/lib/PublicInbox/NetReader.pm +++ b/lib/PublicInbox/NetReader.pm @@ -493,6 +493,9 @@ sub perm_fl_ok ($) { undef; } +# may be overridden in NetWriter or Watch +sub folder_select { $_[0]->{each_old} ? 'select' : 'examine' } + sub _imap_fetch_all ($$$) { my ($self, $mic, $orig_uri) = @_; my $sec = uri_section($orig_uri); @@ -501,7 +504,7 @@ sub _imap_fetch_all ($$$) { # we need to check for mailbox writability to see if we care about # FLAGS from already-imported messages. - my $cmd = $self->{each_old} ? 'select' : 'examine'; + my $cmd = $self->folder_select; $mic->$cmd($mbx) or return "E: \U$cmd\E $mbx ($sec) failed: $!"; my ($r_uidval, $r_uidnext, $perm_fl); diff --git a/lib/PublicInbox/NetWriter.pm b/lib/PublicInbox/NetWriter.pm index 82288e6b..629a752a 100644 --- a/lib/PublicInbox/NetWriter.pm +++ b/lib/PublicInbox/NetWriter.pm @@ -26,6 +26,8 @@ sub imap_append { die "APPEND $folder: $@"; } +sub folder_select { 'select' } # for PublicInbox::NetReader + sub imap_delete_all { my ($self, $uri) = @_; my $mic = $self->mic_for_folder($uri) or return; diff --git a/lib/PublicInbox/Watch.pm b/lib/PublicInbox/Watch.pm index 86dae91f..482d35c4 100644 --- a/lib/PublicInbox/Watch.pm +++ b/lib/PublicInbox/Watch.pm @@ -682,4 +682,6 @@ EOF undef; } +sub folder_select { 'select' } # for PublicInbox::NetReader + 1;