X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=lib%2FPublicInbox%2FIMAPD.pm;h=366b69221cbbf1cbcb2e051cf91862e574dd47ca;hb=ac43c3b17f452b02edf1cce3632a433e998de5ca;hp=186ec7b0062976523bb420eeec3eb768d5ca65aa;hpb=8af34015e9aa94e5ae4ae9e9fd2c4d155453ac94;p=public-inbox.git diff --git a/lib/PublicInbox/IMAPD.pm b/lib/PublicInbox/IMAPD.pm index 186ec7b0..366b6922 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; @@ -37,14 +38,14 @@ sub imapd_refresh_ibx { # pi_config->each_inbox cb } $ibx->over or return; $ibx->{over} = undef; - my $mm = $ibx->mm or return; - $ibx->{mm} = undef; # RFC 3501 2.3.1.1 - "A good UIDVALIDITY value to use in # 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); + eval { $ibx->uidvalidity }; + my $mm = delete($ibx->{mm}) or return; + defined($ibx->{uidvalidity}) or return; + PublicInbox::IMAP::ensure_slices_exist($imapd, $ibx, $mm->max); # preload to avoid fragmentation: $ibx->description; @@ -74,11 +75,6 @@ sub imapd_refresh_finalize { my $u = $_; # capitalize "INBOX" for user-familiarity $u =~ s/\Ainbox(\.|\z)/INBOX$1/i; qq[* LIST (\\Has${no}Children) "." $u\r\n] - } sort { - # shortest names first, alphabetically if lengths match - length($a) == length($b) ? - ($a cmp $b) : - (length($a) <=> length($b)) } keys %$mailboxes ]; $imapd->{pi_config} = $pi_config; @@ -103,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);