- $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);
-
- # preload to avoid fragmentation:
- $ibx->description;
- $ibx->base_url;
-
- # ensure dummies are selectable
- my $dummies = $imapd->{dummies};
- do {
- $dummies->{$ngname} = $dummy;
- } while ($ngname =~ s/\.[^\.]+\z//);
-}
-
-sub imapd_refresh_finalize {
- my ($imapd, $pi_config) = @_;
- my $mailboxes;
- if (my $next = delete $imapd->{imapd_next}) {
- $imapd->{mailboxes} = delete $next->{mailboxes};
- $mailboxes = delete $next->{dummies};
- } else {
- $mailboxes = delete $imapd->{dummies};
- }
- %$mailboxes = (%$mailboxes, %{$imapd->{mailboxes}});
- $imapd->{mailboxes} = $mailboxes;
- $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))
- } keys %$mailboxes
- ];
- $imapd->{pi_config} = $pi_config;
- if (my $idler = $imapd->{idler}) {
- $idler->refresh($pi_config);
- }
-}
-
-sub imapd_refresh_step { # pi_config->iterate_start cb
- my ($pi_config, $section, $imapd) = @_;
- if (defined($section)) {
- return if $section !~ m!\Apublicinbox\.([^/]+)\z!;
- my $ibx = $pi_config->lookup_name($1) or return;
- imapd_refresh_ibx($ibx, $imapd->{imapd_next});
- } else { # undef == "EOF"
- imapd_refresh_finalize($imapd, $pi_config);
+ my $ce = $cache->{$ngname};
+ %$ibx = (%$ibx, %$ce) if $ce;
+ # only valid if msgmap and over works:
+ if (defined($ibx->uidvalidity)) {
+ # fill ->{mailboxes}:
+ PublicInbox::IMAP::ensure_slices_exist($imapd, $ibx);
+ # preload to avoid fragmentation:
+ $ibx->description;
+ # ensure dummies are selectable:
+ do {
+ $dummies->{$ngname} = $dummy;
+ } while ($ngname =~ s/\.[^\.]+\z//);