-sub mbox_all {
- my ($ctx, $query) = @_;
-
- eval { require IO::Compress::Gzip };
- return sub { need_gzip(@_) } if $@;
- if ($query eq '') {
- my $prev = 0;
- my $cb = sub { $ctx->{-inbox}->mm->ids_after(\$prev) };
- 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;
-}
-
-1;
-
-package PublicInbox::MboxGz;
-use strict;
-use warnings;
-use PublicInbox::Hval qw/to_filename/;
-
-sub new {
- my ($class, $ctx, $cb) = @_;
- my $buf = '';
- bless {
- buf => \$buf,
- gz => IO::Compress::Gzip->new(\$buf, Time => 0),
- cb => $cb,
- ctx => $ctx,
- msgs => [],
- }, $class;
+sub all_ids_cb {
+ my ($ctx) = @_;
+ my $over = $ctx->{ibx}->over or return $ctx->gone('over');
+ my $ids = $ctx->{ids};
+ do {
+ while ((my $num = shift @$ids)) {
+ my $smsg = $over->get_art($num) or next;
+ return $smsg;
+ }
+ $ctx->{ids} = $ids = $over->ids_after(\($ctx->{prev}));
+ } while (@$ids);