user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
From: Eric Wong <e@80x24.org>
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	[thread overview]
Message-ID: <20210530063358.25095-3-e@80x24.org> (raw)
In-Reply-To: <20210530063358.25095-1-e@80x24.org>

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;

  parent reply	other threads:[~2021-05-30  6:33 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-30  6:33 [PATCH 0/4] lei lcat usability things Eric Wong
2021-05-30  6:33 ` [PATCH 1/4] lei lcat+inspect: start wiring up completion Eric Wong
2021-05-30  6:33 ` Eric Wong [this message]
2021-05-30  6:33 ` [PATCH 3/4] lei lcat: support maildir: paths, too Eric Wong
2021-05-30  6:33 ` [PATCH 4/4] lei: support implicit stdin by default Eric Wong
2021-05-30 11:52 ` [PATCH 0/4] lei lcat usability things Eric Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210530063358.25095-3-e@80x24.org \
    --to=e@80x24.org \
    --cc=meta@public-inbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).