X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=lib%2FPublicInbox%2FIMAPD.pm;h=3c211ee1bf111568b70040c2b97559f9a88c7580;hb=8fdea96141a65ac85d22d21ed9e3f999259ee73c;hp=6488dc0f3bcbedbdd49fbcd6d2c9580e6f56e533;hpb=4d1a787a0a3c27a11c266b2f76293d09b858b38e;p=public-inbox.git diff --git a/lib/PublicInbox/IMAPD.pm b/lib/PublicInbox/IMAPD.pm index 6488dc0f..3c211ee1 100644 --- a/lib/PublicInbox/IMAPD.pm +++ b/lib/PublicInbox/IMAPD.pm @@ -6,6 +6,7 @@ package PublicInbox::IMAPD; use strict; use PublicInbox::Config; +use PublicInbox::ConfigIter; use PublicInbox::InboxIdle; use PublicInbox::IMAP; use PublicInbox::DummyInbox; @@ -31,7 +32,7 @@ sub imapd_refresh_ibx { # pi_config->each_inbox cb join(', ', @$ngname). "\n"; return; } elsif ($ngname =~ m![^a-z0-9/_\.\-\~\@\+\=:]! || - $ngname =~ /\.[0-9]+-[0-9]+\z/) { + $ngname =~ /\.[0-9]+\z/) { warn "mailbox name invalid: newsgroup=`$ngname'\n"; return; } @@ -44,7 +45,7 @@ sub imapd_refresh_ibx { # pi_config->each_inbox cb # this case is a 32-bit representation of the creation # date/time of the mailbox" defined($ibx->{uidvalidity} = $mm->created_at) or return; - PublicInbox::IMAP::ensure_ranges_exist($imapd, $ibx, $mm->max // 1); + PublicInbox::IMAP::ensure_slices_exist($imapd, $ibx, $mm->max // 0); # preload to avoid fragmentation: $ibx->description; @@ -71,12 +72,9 @@ sub imapd_refresh_finalize { $imapd->{inboxlist} = [ map { my $no = $mailboxes->{$_} == $dummy ? '' : 'No'; - qq[* LIST (\\Has${no}Children) "." $_\r\n] - } sort { - # shortest names first, alphabetically if lengths match - length($a) == length($b) ? - ($a cmp $b) : - (length($a) <=> length($b)) + my $u = $_; # capitalize "INBOX" for user-familiarity + $u =~ s/\Ainbox(\.|\z)/INBOX$1/i; + qq[* LIST (\\Has${no}Children) "." $u\r\n] } keys %$mailboxes ]; $imapd->{pi_config} = $pi_config; @@ -101,8 +99,9 @@ sub refresh_groups { my $pi_config = PublicInbox::Config->new; if ($sig) { # SIGHUP is handled through the event loop $self->{imapd_next} = { dummies => {}, mailboxes => {} }; - $pi_config->iterate_start(\&imapd_refresh_step, $self); - PublicInbox::DS::requeue($pi_config); # call event_step + my $iter = PublicInbox::ConfigIter->new($pi_config, + \&imapd_refresh_step, $self); + $iter->event_step; } else { # initial start is synchronous $self->{dummies} = {}; $pi_config->each_inbox(\&imapd_refresh_ibx, $self);