$title$title
-The administrator needs to install the IO::Compress::Gzip Perl module
-to support gzipped mboxes.
-Return to index
-EOF
- $fh->close;
-}
+sub results_thread_cb {
+ my ($ctx) = @_;
-1;
+ my $over = $ctx->{ibx}->over or return $ctx->gone('over');
+ while (1) {
+ while (defined(my $num = shift(@{$ctx->{xids}}))) {
+ my $smsg = $over->get_art($num) or next;
+ return $smsg;
+ }
-# fh may not be a proper IO, so we wrap the write and close methods
-# to prevent IO::Compress::Gzip from complaining
-package PublicInbox::MboxGz;
-use strict;
-use warnings;
-
-sub new {
- my ($class, $fh) = @_;
- my $buf;
- bless {
- buf => \$buf,
- gz => IO::Compress::Gzip->new(\$buf),
- fh => $fh,
- }, $class;
-}
-
-sub _flush_buf {
- my ($self) = @_;
- if (defined ${$self->{buf}}) {
- $self->{fh}->write(${$self->{buf}});
- ${$self->{buf}} = undef;
+ # refills ctx->{xids}
+ next if $over->expand_thread($ctx);
+
+ # refill result set, deprioritize since there's many results
+ my $srch = $ctx->{ibx}->isrch or return $ctx->gone('search');
+ my $mset = $srch->mset($ctx->{query}, $ctx->{qopts});
+ my $size = $mset->size or return;
+ $ctx->{qopts}->{offset} += $size;
+ $ctx->{ids} = $srch->mset_to_artnums($mset, $ctx->{qopts});
+ $ctx->{-low_prio} = 1;
}
-}
-sub write {
- $_[0]->{gz}->write($_[1]);
- _flush_buf($_[0]);
}
-sub close {
- my ($self) = @_;
- $self->{gz}->close;
- _flush_buf($self);
- $self->{fh}->close;
+sub mbox_all {
+ my ($ctx, $q) = @_;
+ my $q_string = $q->{'q'};
+ return mbox_all_ids($ctx) if $q_string !~ /\S/;
+ my $srch = $ctx->{ibx}->isrch or
+ return PublicInbox::WWW::need($ctx, 'Search');
+ my $over = $ctx->{ibx}->over or
+ return PublicInbox::WWW::need($ctx, 'Overview');
+
+ my $qopts = $ctx->{qopts} = { relevance => -2 }; # ORDER BY docid DESC
+ $qopts->{threads} = 1 if $q->{t};
+ $srch->query_approxidate($ctx->{ibx}->git, $q_string);
+ my $mset = $srch->mset($q_string, $qopts);
+ $qopts->{offset} = $mset->size or
+ return [404, [qw(Content-Type text/plain)],
+ ["No results found\n"]];
+ $ctx->{query} = $q_string;
+ $ctx->{ids} = $srch->mset_to_artnums($mset, $qopts);
+ require PublicInbox::MboxGz;
+ my $fn;
+ if ($q->{t} && $srch->has_threadid) {
+ $fn = 'results-thread-'.$q_string;
+ PublicInbox::MboxGz::mbox_gz($ctx, \&results_thread_cb, $fn);
+ } else {
+ $fn = 'results-'.$q_string;
+ PublicInbox::MboxGz::mbox_gz($ctx, \&results_cb, $fn);
+ }
}
1;