-sub mbox_all {
- my ($ctx, $query) = @_;
-
- eval { require IO::Compress::Gzip };
- return sub { need_gzip(@_) } if $@;
- if ($query eq '') {
- my $prev = 0;
- my $msgs = [];
- my $cb = sub {
- $ctx->{-inbox}->mm->id_batch($prev, sub {
- $msgs = $_[0];
- });
- $prev = $msgs->[-1] if @$msgs;
- $msgs;
- };
- return PublicInbox::MboxGz->response($ctx, $cb, 'all');
- }
- my $opts = { offset => 0 };
- my $srch = $ctx->{srch};
- my $cb = sub { # called by MboxGz->getline
- my $msgs = $srch->query($query, $opts);
- $opts->{offset} += scalar @$msgs;
- $msgs;
- };
- PublicInbox::MboxGz->response($ctx, $cb, 'results-'.$query);
-}
-
-sub need_gzip {
- my $fh = $_[0]->([501, ['Content-Type' => 'text/html']]);
- my $title = 'gzipped mbox not available';
- $fh->write(<<EOF);
-<html><head><title>$title</title><body><pre>$title
-The administrator needs to install the IO::Compress::Gzip Perl module
-to support gzipped mboxes.
-<a href="../">Return to index</a></pre></body></html>
-EOF
- $fh->close;
+sub all_ids_cb {
+ my ($ctx) = @_;
+ my $ids = $ctx->{ids};
+ do {
+ while ((my $num = shift @$ids)) {
+ my $smsg = $ctx->{over}->get_art($num) or next;
+ return $smsg;
+ }
+ $ctx->{ids} = $ids = $ctx->{mm}->ids_after(\($ctx->{prev}));
+ } while (@$ids);