user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download mbox.gz: |
* [PATCH 3/3] imapd: sort LIST response
  2021-09-16  2:19  6% [PATCH 0/3] IMAP and Tor .onion niceities Eric Wong
@ 2021-09-16  2:19  7% ` Eric Wong
  0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2021-09-16  2:19 UTC (permalink / raw)
  To: meta

While RFC 3501 doesn't require LIST responses be sorted,
it makes reading protocol dumps easier and we memoize it
once per-refresh, so it shouldn't be too expensive even
with thousands of folders.
---
 lib/PublicInbox/IMAP.pm  |  4 ++--
 lib/PublicInbox/IMAPD.pm | 15 ++++++++++++---
 2 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/lib/PublicInbox/IMAP.pm b/lib/PublicInbox/IMAP.pm
index 37e07dae..27013ea5 100644
--- a/lib/PublicInbox/IMAP.pm
+++ b/lib/PublicInbox/IMAP.pm
@@ -384,7 +384,7 @@ sub ensure_slices_exist ($$$) {
 		push @created, $sub_mailbox;
 	}
 	return unless @created;
-	my $l = $imapd->{inboxlist} or return;
+	my $l = $imapd->{mailboxlist} or return;
 	push @$l, map { qq[* LIST (\\HasNoChildren) "." $_\r\n] } @created;
 }
 
@@ -850,7 +850,7 @@ sub cmd_status ($$$;@) {
 my %patmap = ('*' => '.*', '%' => '[^\.]*');
 sub cmd_list ($$$$) {
 	my ($self, $tag, $refname, $wildcard) = @_;
-	my $l = $self->{imapd}->{inboxlist};
+	my $l = $self->{imapd}->{mailboxlist};
 	if ($refname eq '' && $wildcard eq '') {
 		# request for hierarchy delimiter
 		$l = [ qq[* LIST (\\Noselect) "." ""\r\n] ];
diff --git a/lib/PublicInbox/IMAPD.pm b/lib/PublicInbox/IMAPD.pm
index 7425409d..6aa3d12f 100644
--- a/lib/PublicInbox/IMAPD.pm
+++ b/lib/PublicInbox/IMAPD.pm
@@ -70,12 +70,21 @@ sub imapd_refresh_finalize {
 	}
 	%$mailboxes = (%$mailboxes, %{$imapd->{mailboxes}});
 	$imapd->{mailboxes} = $mailboxes;
-	$imapd->{inboxlist} = [
+	$imapd->{mailboxlist} = [
+		map { $_->[2] }
+		sort { $a->[0] cmp $b->[0] || $a->[1] <=> $b->[1] }
 		map {
-			my $no = $mailboxes->{$_} == $dummy ? '' : 'No';
 			my $u = $_; # capitalize "INBOX" for user-familiarity
 			$u =~ s/\Ainbox(\.|\z)/INBOX$1/i;
-			qq[* LIST (\\Has${no}Children) "." $u\r\n]
+			if ($mailboxes->{$_} == $dummy) {
+				[ $u, -1,
+				  qq[* LIST (\\HasChildren) "." $u\r\n]]
+			} else {
+				$u =~ /\A(.+)\.([0-9]+)\z/ or
+					die "BUG: `$u' has no slice digit(s)";
+				[ $1, $2 + 0,
+				  qq[* LIST (\\HasNoChildren) "." $u\r\n] ]
+			}
 		} keys %$mailboxes
 	];
 	$imapd->{pi_cfg} = $pi_cfg;

^ permalink raw reply related	[relevance 7%]

* [PATCH 0/3] IMAP and Tor .onion niceities
@ 2021-09-16  2:19  6% Eric Wong
  2021-09-16  2:19  7% ` [PATCH 3/3] imapd: sort LIST response Eric Wong
  0 siblings, 1 reply; 2+ results
From: Eric Wong @ 2021-09-16  2:19 UTC (permalink / raw)
  To: meta

Some things I noticed while writing a quick how-to on
"lei ls-mail-source" and .onion usage in
https://public-inbox.org/meta/20210915230605.GA22173@dcvr/

Eric Wong (3):
  net_reader: emit .onion help for potential Tor users
  lei ls-mail-source: sort IMAP folder names
  imapd: sort LIST response

 lib/PublicInbox/IMAP.pm            |  4 ++--
 lib/PublicInbox/IMAPD.pm           | 15 ++++++++++++---
 lib/PublicInbox/LeiLsMailSource.pm |  6 ++++++
 lib/PublicInbox/NetReader.pm       | 30 +++++++++++++++++++++++++++---
 4 files changed, 47 insertions(+), 8 deletions(-)

^ permalink raw reply	[relevance 6%]

Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2021-09-16  2:19  6% [PATCH 0/3] IMAP and Tor .onion niceities Eric Wong
2021-09-16  2:19  7% ` [PATCH 3/3] imapd: sort LIST response Eric Wong

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).