Having two large numbers separated by a dash can make visual
comparisons difficult when numbers are in the 3,000,000 range
for LKML. So avoid the $UID_END value, since it can be
calculated from $UID_MIN. And we can avoid large values of
$UID_MIN, too, by instead storing the block index and just
multiplying it by 50000 (and adding 1) on the server side.
Of course, LKML still goes up to 72, at the moment.
my $mailboxes = $imapd->{mailboxes};
my $mb_top = $ibx->{newsgroup};
my @created;
my $mailboxes = $imapd->{mailboxes};
my $mb_top = $ibx->{newsgroup};
my @created;
- my $uid_min = UID_BLOCK * int($max/UID_BLOCK) + 1;
- my $uid_end = $uid_min + UID_BLOCK - 1;
- while ($uid_min > 0) {
- my $sub_mailbox = "$mb_top.$uid_min-$uid_end";
+ for (my $i = int($max/UID_BLOCK); $i >= 0; --$i) {
+ my $sub_mailbox = "$mb_top.$i";
last if exists $mailboxes->{$sub_mailbox};
$mailboxes->{$sub_mailbox} = $ibx;
last if exists $mailboxes->{$sub_mailbox};
$mailboxes->{$sub_mailbox} = $ibx;
- $uid_end -= UID_BLOCK;
- $uid_min -= UID_BLOCK;
push @created, $sub_mailbox;
}
return unless @created;
push @created, $sub_mailbox;
}
return unless @created;
my ($self, $tag, $mailbox) = @_;
my ($ibx, $mm, $max);
my ($self, $tag, $mailbox) = @_;
my ($ibx, $mm, $max);
- if ($mailbox =~ /\A(.+)\.([0-9]+)-([0-9]+)\z/) {
- # old mail: inbox.comp.foo.$uid_min-$uid_end
- my ($mb_top, $uid_min, $uid_end) = ($1, $2 + 0, $3 + 0);
+ if ($mailbox =~ /\A(.+)\.([0-9]+)\z/) {
+ # old mail: inbox.comp.foo.$uid_block_idx
+ my ($mb_top, $uid_min) = ($1, $2 * UID_BLOCK + 1);
$ibx = $self->{imapd}->{mailboxes}->{lc $mailbox} or
return "$tag NO Mailbox doesn't exist: $mailbox\r\n";
$ibx = $self->{imapd}->{mailboxes}->{lc $mailbox} or
return "$tag NO Mailbox doesn't exist: $mailbox\r\n";
$max = $mm->max // 0;
$self->{uid_min} = $uid_min;
ensure_ranges_exist($self->{imapd}, $ibx, $max);
$max = $mm->max // 0;
$self->{uid_min} = $uid_min;
ensure_ranges_exist($self->{imapd}, $ibx, $max);
+ my $uid_end = $uid_min + UID_BLOCK - 1;
$max = $uid_end if $max > $uid_end;
} else { # check for dummy inboxes
$ibx = $self->{imapd}->{mailboxes}->{lc $mailbox} or
$max = $uid_end if $max > $uid_end;
} else { # check for dummy inboxes
$ibx = $self->{imapd}->{mailboxes}->{lc $mailbox} or
join(', ', @$ngname). "\n";
return;
} elsif ($ngname =~ m![^a-z0-9/_\.\-\~\@\+\=:]! ||
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;
}
warn "mailbox name invalid: newsgroup=`$ngname'\n";
return;
}
}
require_ok 'PublicInbox::IMAP';
}
require_ok 'PublicInbox::IMAP';
-my $first_range = '1-'.PublicInbox::IMAP::UID_BLOCK();
my $level = '-Lbasic';
SKIP: {
my $level = '-Lbasic';
SKIP: {
my ($tmpdir, $for_destroy) = tmpdir();
my $cfg = "$tmpdir/cfg";
my $newsgroup = 'inbox.test';
my ($tmpdir, $for_destroy) = tmpdir();
my $cfg = "$tmpdir/cfg";
my $newsgroup = 'inbox.test';
-my $mailbox = "$newsgroup.1-50000";
+my $mailbox = "$newsgroup.0";
{
open my $fh, '>', $cfg or BAIL_OUT "open: $!";
print $fh <<EOF or BAIL_OUT "print: $!";
{
open my $fh, '>', $cfg or BAIL_OUT "open: $!";
print $fh <<EOF or BAIL_OUT "print: $!";
} else {
require_mods(qw(DBD::SQLite));
$make_local_server->();
} else {
require_mods(qw(DBD::SQLite));
$make_local_server->();
- $mailbox = "$newsgroup.1-50000";
+ $mailbox = "$newsgroup.0";
}
my %opts = (imap => \%OPT, 'imap+compress' => { %OPT, Compress => 1 });
}
my %opts = (imap => \%OPT, 'imap+compress' => { %OPT, Compress => 1 });