diff options
-rw-r--r-- | lib/PublicInbox/POP3.pm | 18 | ||||
-rw-r--r-- | xt/pop3d-mpop.t | 4 |
2 files changed, 14 insertions, 8 deletions
diff --git a/lib/PublicInbox/POP3.pm b/lib/PublicInbox/POP3.pm index d32793e4..4a21ef5e 100644 --- a/lib/PublicInbox/POP3.pm +++ b/lib/PublicInbox/POP3.pm @@ -41,6 +41,7 @@ use PublicInbox::IMAP; # for UID slice stuff use constant { LINE_MAX => 512, # XXX unsure + UID_SLICE => PublicInbox::IMAP::UID_SLICE, }; # XXX FIXME: duplicated stuff from NNTP.pm and IMAP.pm @@ -70,20 +71,25 @@ sub cmd_user ($$) { my $user = $1; $user =~ tr/-//d; # most have dashes, some (dbus-uuidgen) don't $user =~ m!\A[a-f0-9]{32}\z!i or return \"-ERR user has no UUID\r\n"; - my $slice; - $mailbox =~ s/\.([0-9]+)\z// and $slice = $1 + 0; + + my $limit = UID_SLICE; + $mailbox =~ s/\?limit=([0-9]+)\z// and + $limit = $1 > UID_SLICE ? UID_SLICE : $1; + + my $slice = $mailbox =~ s/\.([0-9]+)\z// ? $1 + 0 : undef; + my $ibx = $self->{pop3d}->{pi_cfg}->lookup_newsgroup($mailbox) // return \"-ERR $mailbox does not exist\r\n"; my $uidmax = $ibx->mm(1)->num_highwater // 0; if (defined $slice) { - my $max = int($uidmax / PublicInbox::IMAP::UID_SLICE); + my $max = int($uidmax / UID_SLICE); my $tip = "$mailbox.$max"; return \"-ERR $mailbox.$slice does not exist ($tip does)\r\n" if $slice > $max; - $self->{uid_base} = $slice * PublicInbox::IMAP::UID_SLICE; + $self->{uid_base} = ($slice * UID_SLICE) + UID_SLICE - $limit; $self->{slice} = $slice; - } else { # latest 50K messages - my $base = $uidmax - PublicInbox::IMAP::UID_SLICE; + } else { # latest $limit messages + my $base = $uidmax - $limit; $self->{uid_base} = $base < 0 ? 0 : $base; $self->{slice} = -1; } diff --git a/xt/pop3d-mpop.t b/xt/pop3d-mpop.t index fc82bc6b..9da1050c 100644 --- a/xt/pop3d-mpop.t +++ b/xt/pop3d-mpop.t @@ -53,7 +53,7 @@ delivery maildir $tmpdir/md account default host ${\$sock->sockhost} port ${\$sock->sockport} -user $uuid\@$newsgroup +user $uuid\@$newsgroup?limit=10000 auth user password anonymous received_header off @@ -65,7 +65,7 @@ EOM my $pid = spawn($cmd, undef, { 1 => 2 }); $pids{$pid} = $cmd; } - +diag "mpop is writing to $tmpdir/md ..."; while (scalar keys %pids) { my $pid = waitpid(-1, 0) or next; my $cmd = delete $pids{$pid} or next; |