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 E257D1F9F3 for ; Sun, 30 May 2021 06:33:58 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 2/4] lei lcat: allow IMAP folder URLs w/o UIDVALIDITY Date: Sun, 30 May 2021 06:33:56 +0000 Message-Id: <20210530063358.25095-3-e@80x24.org> In-Reply-To: <20210530063358.25095-1-e@80x24.org> References: <20210530063358.25095-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Requiring UIDVALIDITY on the command-line is of course unreasonable. --- lib/PublicInbox/LeiLcat.pm | 12 +++++++++++- t/lei-import-imap.t | 3 +++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/PublicInbox/LeiLcat.pm b/lib/PublicInbox/LeiLcat.pm index 81ab1e36..5bd20c1f 100644 --- a/lib/PublicInbox/LeiLcat.pm +++ b/lib/PublicInbox/LeiLcat.pm @@ -24,7 +24,17 @@ sub lcat_imap_uri ($$) { } elsif (defined(my $fid = $lms->fid_for($$uri))) { push @{$lei->{lcat_fid}}, $fid; } else { - $lei->child_error(1 << 8, "# unknown folder: $uri"); + my $folders = [ $$uri ]; + my $err = $lms->arg2folder($lei, $folders); + $lei->qerr(@{$err->{qerr}}) if $err && $err->{qerr}; + if ($err && $err->{fail}) { + $lei->child_error(1 << 8, "# unknown folder: $uri"); + } else { + for my $f (@$folders) { + my $fid = $lms->fid_for($f); + push @{$lei->{lcat_fid}}, $fid; + } + } } } diff --git a/t/lei-import-imap.t b/t/lei-import-imap.t index 895b19ff..34fd6cf9 100644 --- a/t/lei-import-imap.t +++ b/t/lei-import-imap.t @@ -13,6 +13,7 @@ my $host_port = tcp_host_port($sock); undef $sock; test_lei({ tmpdir => $tmpdir }, sub { my $url = "imap://$host_port/t.v2.0"; + my $url_orig = $url; lei_ok(qw(q z:1..)); my $out = json_utf8->decode($lei_out); @@ -100,6 +101,8 @@ test_lei({ tmpdir => $tmpdir }, sub { lei_ok qw(lcat -f json), $uid_url; $out = json_utf8->decode($lei_out); 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'); }); done_testing;