From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 2/3] lei ls-mail-source: sort IMAP folder names
Date: Wed, 15 Sep 2021 21:19:42 -0500 [thread overview]
Message-ID: <20210916021943.22529-3-e@80x24.org> (raw)
In-Reply-To: <20210916021943.22529-1-e@80x24.org>
Otherwise, public-inbox-imapd will emit mailboxes in random
order (as IMAP servers do not need to guarantee any sort of
ordering). We'll take into account numeric slice numbers
generated by -imapd if they exist, so slice "80" doesn't show up
next to "8".
---
lib/PublicInbox/LeiLsMailSource.pm | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/lib/PublicInbox/LeiLsMailSource.pm b/lib/PublicInbox/LeiLsMailSource.pm
index 71e253d9..f012e10e 100644
--- a/lib/PublicInbox/LeiLsMailSource.pm
+++ b/lib/PublicInbox/LeiLsMailSource.pm
@@ -27,6 +27,12 @@ sub input_path_url { # overrides LeiInput version
my $sec = $lei->{net}->can('uri_section')->($uri);
my $mic = $lei->{net}->mic_get($uri);
my $l = $mic->folders_hash($uri->path); # server-side filter
+ @$l = map { $_->[2] } # undo Schwartzian transform below:
+ sort { $a->[0] cmp $b->[0] || $a->[1] <=> $b->[1] }
+ map { # prepare to sort -imapd slices numerically
+ $_->{name} =~ /\A(.+?)\.([0-9]+)\z/ ?
+ [ $1, $2 + 0, $_ ] : [ $_->{name}, -1, $_ ];
+ } @$l;
@f = map { "$sec/$_->{name}" } @$l;
if ($json) {
$_->{url} = "$sec/$_->{name}" for @$l;
next prev parent reply other threads:[~2021-09-16 2:19 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-16 2:19 [PATCH 0/3] IMAP and Tor .onion niceities Eric Wong
2021-09-16 2:19 ` [PATCH 1/3] net_reader: emit .onion help for potential Tor users Eric Wong
2021-09-16 2:19 ` Eric Wong [this message]
2021-09-16 2:19 ` [PATCH 3/3] imapd: sort LIST response 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=20210916021943.22529-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.
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).